Class: Charming::KeyEvent

Inherits:
Data
  • Object
show all
Defined in:
lib/charming/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.



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

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



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

def alt
  @alt
end

#charObject (readonly)

Returns the value of attribute char

Returns:

  • (Object)

    the current value of char



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

def char
  @char
end

#ctrlObject (readonly)

Returns the value of attribute ctrl

Returns:

  • (Object)

    the current value of ctrl



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

def ctrl
  @ctrl
end

#keyObject (readonly)

Returns the value of attribute key

Returns:

  • (Object)

    the current value of key



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

def key
  @key
end

#shiftObject (readonly)

Returns the value of attribute shift

Returns:

  • (Object)

    the current value of shift



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

def shift
  @shift
end