Class: Charming::Events::KeyEvent

Inherits:
Data
  • Object
show all
Defined in:
lib/charming/events/key_event.rb

Overview

KeyEvent represents a terminal key press parsed by the backend. key is the normalized semantic action name (e.g., ‘:up`, `:down`, `:q`), while char, ctrl, alt, and shift capture raw input details for custom bindings.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key:, char: nil, ctrl: false, alt: false, shift: false) ⇒ KeyEvent

Constructs a key event with the required key symbol, plus optional char string and modifier booleans.



10
11
12
# File 'lib/charming/events/key_event.rb', line 10

def initialize(key:, char: nil, ctrl: false, alt: false, shift: false)
  super(key: key.to_sym, char: char, ctrl: ctrl, alt: alt, shift: shift)
end

Instance Attribute Details

#altObject (readonly)

Returns the value of attribute alt

Returns:

  • (Object)

    the current value of alt



8
9
10
# File 'lib/charming/events/key_event.rb', line 8

def alt
  @alt
end

#charObject (readonly)

Returns the value of attribute char

Returns:

  • (Object)

    the current value of char



8
9
10
# File 'lib/charming/events/key_event.rb', line 8

def char
  @char
end

#ctrlObject (readonly)

Returns the value of attribute ctrl

Returns:

  • (Object)

    the current value of ctrl



8
9
10
# File 'lib/charming/events/key_event.rb', line 8

def ctrl
  @ctrl
end

#keyObject (readonly)

Returns the value of attribute key

Returns:

  • (Object)

    the current value of key



8
9
10
# File 'lib/charming/events/key_event.rb', line 8

def key
  @key
end

#shiftObject (readonly)

Returns the value of attribute shift

Returns:

  • (Object)

    the current value of shift



8
9
10
# File 'lib/charming/events/key_event.rb', line 8

def shift
  @shift
end