struct

Termisu::Event::Key

Inherits Struct / Value / Object

Keyboard input event.

Contains the key pressed and any modifier keys that were held.

Example:

event = termisu.poll_event
if event.is_a?(Termisu::Event::Key)
  if event.ctrl_c?
    puts "Ctrl+C pressed, exiting..."
  elsif event.key.escape?
    puts "Escape pressed"
  end
end

Constructors

new(key : Input::Key, modifiers : Input::Modifier = Input::Modifier::None, char : Char | Nil = nil)
Source

Instance methods

alt?

Returns true if Alt modifier was held.

Source
char

Returns the character for this key, if printable. Prefers the explicitly attached @char (for full Unicode input).

Source
ctrl?

Returns true if Ctrl modifier was held.

Source
ctrl_c?

Returns true if this is Ctrl+C.

Source
ctrl_d?

Returns true if this is Ctrl+D.

Source
ctrl_q?

Returns true if this is Ctrl+Q.

Source
ctrl_z?

Returns true if this is Ctrl+Z.

Source
key

The key that was pressed.

Source
meta?

Returns true if Meta modifier was held.

Source
modifiers

Modifier keys held during the keypress.

Source
shift?

Returns true if Shift modifier was held.

Source