Class: Plushie::Event::Key

Inherits:
Data
  • Object
show all
Defined in:
lib/plushie/event.rb

Overview

Keyboard events delivered when keys are pressed or released. Triggered by keyboard input while the window has focus. Subscribe via Subscription.on_key_press or Subscription.on_key_release.

Examples:

Key press with modifier

in Event::Key[type: :press, key: "s", modifiers: { command: true }]

Any key release

in Event::Key[type: :release, key:]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, key:, modified_key: nil, physical_key: nil, location: :standard, modifiers: {}, text: nil, repeat: false, captured: false) ⇒ Key

Returns a new instance of Key.



56
57
58
59
# File 'lib/plushie/event.rb', line 56

def initialize(type:, key:, modified_key: nil, physical_key: nil,
  location: :standard, modifiers: {}, text: nil, repeat: false, captured: false)
  super
end

Instance Attribute Details

#capturedObject (readonly)

Returns the value of attribute captured

Returns:

  • (Object)

    the current value of captured



54
55
56
# File 'lib/plushie/event.rb', line 54

def captured
  @captured
end

#captured [Boolean] true if a widget consumed this event([Boolean]) ⇒ Object (readonly)

Keyboard events delivered when keys are pressed or released. Triggered by keyboard input while the window has focus. Subscribe via Subscription.on_key_press or Subscription.on_key_release.

Examples:

Key press with modifier

in Event::Key[type: :press, key: "s", modifiers: { command: true }]

Any key release

in Event::Key[type: :release, key:]


54
55
56
57
58
59
60
# File 'lib/plushie/event.rb', line 54

Key = Data.define(:type, :key, :modified_key, :physical_key,
  :location, :modifiers, :text, :repeat, :captured) do
  def initialize(type:, key:, modified_key: nil, physical_key: nil,
    location: :standard, modifiers: {}, text: nil, repeat: false, captured: false)
    super
  end
end

#keyObject (readonly)

Returns the value of attribute key

Returns:

  • (Object)

    the current value of key



54
55
56
# File 'lib/plushie/event.rb', line 54

def key
  @key
end

#key [String] logical key name ("a", "Enter", "ArrowUp", etc.)([String]("a", "Enter", "ArrowUp", etc.)) ⇒ Object (readonly)

Keyboard events delivered when keys are pressed or released. Triggered by keyboard input while the window has focus. Subscribe via Subscription.on_key_press or Subscription.on_key_release.

Examples:

Key press with modifier

in Event::Key[type: :press, key: "s", modifiers: { command: true }]

Any key release

in Event::Key[type: :release, key:]


54
55
56
57
58
59
60
# File 'lib/plushie/event.rb', line 54

Key = Data.define(:type, :key, :modified_key, :physical_key,
  :location, :modifiers, :text, :repeat, :captured) do
  def initialize(type:, key:, modified_key: nil, physical_key: nil,
    location: :standard, modifiers: {}, text: nil, repeat: false, captured: false)
    super
  end
end

#locationObject (readonly)

Returns the value of attribute location

Returns:

  • (Object)

    the current value of location



54
55
56
# File 'lib/plushie/event.rb', line 54

def location
  @location
end

#location [Symbol] key location (:standard, :left, :right, :numpad)([Symbol](: standard, :left, :right, :numpad)) ⇒ Object (readonly)

Keyboard events delivered when keys are pressed or released. Triggered by keyboard input while the window has focus. Subscribe via Subscription.on_key_press or Subscription.on_key_release.

Examples:

Key press with modifier

in Event::Key[type: :press, key: "s", modifiers: { command: true }]

Any key release

in Event::Key[type: :release, key:]


54
55
56
57
58
59
60
# File 'lib/plushie/event.rb', line 54

Key = Data.define(:type, :key, :modified_key, :physical_key,
  :location, :modifiers, :text, :repeat, :captured) do
  def initialize(type:, key:, modified_key: nil, physical_key: nil,
    location: :standard, modifiers: {}, text: nil, repeat: false, captured: false)
    super
  end
end

#modified_keyObject (readonly)

Returns the value of attribute modified_key

Returns:

  • (Object)

    the current value of modified_key



54
55
56
# File 'lib/plushie/event.rb', line 54

def modified_key
  @modified_key
end

#modified_key [String, nil] key with modifiers applied (e.g. "S" for shift+s)([String, nil](e.g. "S") ⇒ Object (readonly)

Keyboard events delivered when keys are pressed or released. Triggered by keyboard input while the window has focus. Subscribe via Subscription.on_key_press or Subscription.on_key_release.

Examples:

Key press with modifier

in Event::Key[type: :press, key: "s", modifiers: { command: true }]

Any key release

in Event::Key[type: :release, key:]


54
55
56
57
58
59
60
# File 'lib/plushie/event.rb', line 54

Key = Data.define(:type, :key, :modified_key, :physical_key,
  :location, :modifiers, :text, :repeat, :captured) do
  def initialize(type:, key:, modified_key: nil, physical_key: nil,
    location: :standard, modifiers: {}, text: nil, repeat: false, captured: false)
    super
  end
end

#modifiersObject (readonly)

Returns the value of attribute modifiers

Returns:

  • (Object)

    the current value of modifiers



54
55
56
# File 'lib/plushie/event.rb', line 54

def modifiers
  @modifiers
end

#modifiers [Hash] active modifier state ({shift: true, command: false, ...})([Hash]({shift: true, command: false, ...})) ⇒ Object (readonly)

Keyboard events delivered when keys are pressed or released. Triggered by keyboard input while the window has focus. Subscribe via Subscription.on_key_press or Subscription.on_key_release.

Examples:

Key press with modifier

in Event::Key[type: :press, key: "s", modifiers: { command: true }]

Any key release

in Event::Key[type: :release, key:]


54
55
56
57
58
59
60
# File 'lib/plushie/event.rb', line 54

Key = Data.define(:type, :key, :modified_key, :physical_key,
  :location, :modifiers, :text, :repeat, :captured) do
  def initialize(type:, key:, modified_key: nil, physical_key: nil,
    location: :standard, modifiers: {}, text: nil, repeat: false, captured: false)
    super
  end
end

#physical_keyObject (readonly)

Returns the value of attribute physical_key

Returns:

  • (Object)

    the current value of physical_key



54
55
56
# File 'lib/plushie/event.rb', line 54

def physical_key
  @physical_key
end

#physical_key [String, nil] hardware scan code name([String, nil]) ⇒ Object (readonly)

Keyboard events delivered when keys are pressed or released. Triggered by keyboard input while the window has focus. Subscribe via Subscription.on_key_press or Subscription.on_key_release.

Examples:

Key press with modifier

in Event::Key[type: :press, key: "s", modifiers: { command: true }]

Any key release

in Event::Key[type: :release, key:]


54
55
56
57
58
59
60
# File 'lib/plushie/event.rb', line 54

Key = Data.define(:type, :key, :modified_key, :physical_key,
  :location, :modifiers, :text, :repeat, :captured) do
  def initialize(type:, key:, modified_key: nil, physical_key: nil,
    location: :standard, modifiers: {}, text: nil, repeat: false, captured: false)
    super
  end
end

#repeatObject (readonly)

Returns the value of attribute repeat

Returns:

  • (Object)

    the current value of repeat



54
55
56
# File 'lib/plushie/event.rb', line 54

def repeat
  @repeat
end

#repeat [Boolean] true if this is a key-repeat event([Boolean]) ⇒ Object (readonly)

Keyboard events delivered when keys are pressed or released. Triggered by keyboard input while the window has focus. Subscribe via Subscription.on_key_press or Subscription.on_key_release.

Examples:

Key press with modifier

in Event::Key[type: :press, key: "s", modifiers: { command: true }]

Any key release

in Event::Key[type: :release, key:]


54
55
56
57
58
59
60
# File 'lib/plushie/event.rb', line 54

Key = Data.define(:type, :key, :modified_key, :physical_key,
  :location, :modifiers, :text, :repeat, :captured) do
  def initialize(type:, key:, modified_key: nil, physical_key: nil,
    location: :standard, modifiers: {}, text: nil, repeat: false, captured: false)
    super
  end
end

#textObject (readonly)

Returns the value of attribute text

Returns:

  • (Object)

    the current value of text



54
55
56
# File 'lib/plushie/event.rb', line 54

def text
  @text
end

#text [String, nil] text produced by the key event (nil for non-printable keys)([String, nil](nil) ⇒ Object (readonly)

Keyboard events delivered when keys are pressed or released. Triggered by keyboard input while the window has focus. Subscribe via Subscription.on_key_press or Subscription.on_key_release.

Examples:

Key press with modifier

in Event::Key[type: :press, key: "s", modifiers: { command: true }]

Any key release

in Event::Key[type: :release, key:]


54
55
56
57
58
59
60
# File 'lib/plushie/event.rb', line 54

Key = Data.define(:type, :key, :modified_key, :physical_key,
  :location, :modifiers, :text, :repeat, :captured) do
  def initialize(type:, key:, modified_key: nil, physical_key: nil,
    location: :standard, modifiers: {}, text: nil, repeat: false, captured: false)
    super
  end
end

#typeObject (readonly)

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



54
55
56
# File 'lib/plushie/event.rb', line 54

def type
  @type
end

#type [Symbol] :press or :release([Symbol]) ⇒ Object (readonly)

Keyboard events delivered when keys are pressed or released. Triggered by keyboard input while the window has focus. Subscribe via Subscription.on_key_press or Subscription.on_key_release.

Examples:

Key press with modifier

in Event::Key[type: :press, key: "s", modifiers: { command: true }]

Any key release

in Event::Key[type: :release, key:]


54
55
56
57
58
59
60
# File 'lib/plushie/event.rb', line 54

Key = Data.define(:type, :key, :modified_key, :physical_key,
  :location, :modifiers, :text, :repeat, :captured) do
  def initialize(type:, key:, modified_key: nil, physical_key: nil,
    location: :standard, modifiers: {}, text: nil, repeat: false, captured: false)
    super
  end
end