Key enum representing all keyboard keys.
Each key has its own enum value for type-safe key handling.
Modifiers (Ctrl, Alt, Shift) are tracked separately in the Modifier flags.
Example:
event = termisu.poll_event
if event.is_a?(Termisu::Event::Key)
case event.key
when .escape? then puts "Escape pressed"
when .enter? then puts "Enter pressed"
when .lower_a? then puts "a pressed"
when .upper_a? then puts "A pressed"
end
end
Constants
Backtick = 62
Punctuation & Symbols (unshifted)
CapsLock = 133
Special / Modifier keys (only detectable with enhanced keyboard protocols)
PasteStart = 140
Bracketed paste boundaries (DEC private mode 2004), only ever reported
while Terminal#enable_bracketed_paste is active.
These are not keystrokes: they bracket a run of bytes the terminal pasted
verbatim, so a caller can tell a pasted line break from one the operator
typed. The bytes between them are reported unchanged — a pasted CR is
still Enter with char == '\r'.
Appended after Unknown deliberately. key_code crosses the C ABI and the
JS binding as a plain integer with no enum mirror on the other side (see
FFI::Conversions.write_key_event), so inserting these next to the other
non-character keys would renumber every key above them.
Constructors
from_char(c : Char) : Key
Creates a Key from a printable character.
Maps ASCII characters to their corresponding Key enum values.
Returns Key::Unknown for unmapped characters.
SourceInstance methods
ampersand?
Returns true if this enum value equals Ampersand
Sourceasterisk?
Returns true if this enum value equals Asterisk
Sourceat?
Returns true if this enum value equals At
Sourceback_tab?
Returns true if this enum value equals BackTab
Sourcebackslash?
Returns true if this enum value equals Backslash
Sourcebackspace?
Returns true if this enum value equals Backspace
Sourcebacktick?
Returns true if this enum value equals Backtick
Sourcecaps_lock?
Returns true if this enum value equals CapsLock
Sourcecaret?
Returns true if this enum value equals Caret
Sourcecolon?
Returns true if this enum value equals Colon
Sourcecomma?
Returns true if this enum value equals Comma
Sourcedelete?
Returns true if this enum value equals Delete
Sourcedigit?
Returns true if this is a digit key (0-9).
Sourcedollar?
Returns true if this enum value equals Dollar
Sourcedouble_quote?
Returns true if this enum value equals DoubleQuote
Sourcedown?
Returns true if this enum value equals Down
Sourceend?
Returns true if this enum value equals End
Sourceenter?
Returns true if this enum value equals Enter
Sourceequals?
Returns true if this enum value equals Equals
Sourceescape?
Returns true if this enum value equals Escape
Sourceexclaim?
Returns true if this enum value equals Exclaim
Sourcef10?
Returns true if this enum value equals F10
Sourcef11?
Returns true if this enum value equals F11
Sourcef12?
Returns true if this enum value equals F12
Sourcef13?
Returns true if this enum value equals F13
Sourcef14?
Returns true if this enum value equals F14
Sourcef15?
Returns true if this enum value equals F15
Sourcef16?
Returns true if this enum value equals F16
Sourcef17?
Returns true if this enum value equals F17
Sourcef18?
Returns true if this enum value equals F18
Sourcef19?
Returns true if this enum value equals F19
Sourcef1?
Returns true if this enum value equals F1
Sourcef20?
Returns true if this enum value equals F20
Sourcef21?
Returns true if this enum value equals F21
Sourcef22?
Returns true if this enum value equals F22
Sourcef23?
Returns true if this enum value equals F23
Sourcef24?
Returns true if this enum value equals F24
Sourcef2?
Returns true if this enum value equals F2
Sourcef3?
Returns true if this enum value equals F3
Sourcef4?
Returns true if this enum value equals F4
Sourcef5?
Returns true if this enum value equals F5
Sourcef6?
Returns true if this enum value equals F6
Sourcef7?
Returns true if this enum value equals F7
Sourcef8?
Returns true if this enum value equals F8
Sourcef9?
Returns true if this enum value equals F9
Sourcefunction_key?
Returns true if this is a function key (F1-F24).
Sourcegreater_than?
Returns true if this enum value equals GreaterThan
Sourcehash?
Returns true if this enum value equals Hash
Sourcehome?
Returns true if this enum value equals Home
Sourceinsert?
Returns true if this enum value equals Insert
Sourceleft?
Returns true if this enum value equals Left
Sourceleft_brace?
Returns true if this enum value equals LeftBrace
Sourceleft_bracket?
Returns true if this enum value equals LeftBracket
Sourceleft_paren?
Returns true if this enum value equals LeftParen
Sourceless_than?
Returns true if this enum value equals LessThan
Sourceletter?
Returns true if this is a letter key (A-Z or a-z).
Sourcelower_a?
Returns true if this enum value equals LowerA
Sourcelower_b?
Returns true if this enum value equals LowerB
Sourcelower_c?
Returns true if this enum value equals LowerC
Sourcelower_d?
Returns true if this enum value equals LowerD
Sourcelower_e?
Returns true if this enum value equals LowerE
Sourcelower_f?
Returns true if this enum value equals LowerF
Sourcelower_g?
Returns true if this enum value equals LowerG
Sourcelower_h?
Returns true if this enum value equals LowerH
Sourcelower_i?
Returns true if this enum value equals LowerI
Sourcelower_j?
Returns true if this enum value equals LowerJ
Sourcelower_k?
Returns true if this enum value equals LowerK
Sourcelower_l?
Returns true if this enum value equals LowerL
Sourcelower_m?
Returns true if this enum value equals LowerM
Sourcelower_n?
Returns true if this enum value equals LowerN
Sourcelower_o?
Returns true if this enum value equals LowerO
Sourcelower_p?
Returns true if this enum value equals LowerP
Sourcelower_q?
Returns true if this enum value equals LowerQ
Sourcelower_r?
Returns true if this enum value equals LowerR
Sourcelower_s?
Returns true if this enum value equals LowerS
Sourcelower_t?
Returns true if this enum value equals LowerT
Sourcelower_u?
Returns true if this enum value equals LowerU
Sourcelower_v?
Returns true if this enum value equals LowerV
Sourcelower_w?
Returns true if this enum value equals LowerW
Sourcelower_x?
Returns true if this enum value equals LowerX
Sourcelower_y?
Returns true if this enum value equals LowerY
Sourcelower_z?
Returns true if this enum value equals LowerZ
Sourceminus?
Returns true if this enum value equals Minus
Sourcenavigation?
Returns true if this is a navigation key.
Sourcenum0?
Returns true if this enum value equals Num0
Sourcenum1?
Returns true if this enum value equals Num1
Sourcenum2?
Returns true if this enum value equals Num2
Sourcenum3?
Returns true if this enum value equals Num3
Sourcenum4?
Returns true if this enum value equals Num4
Sourcenum5?
Returns true if this enum value equals Num5
Sourcenum6?
Returns true if this enum value equals Num6
Sourcenum7?
Returns true if this enum value equals Num7
Sourcenum8?
Returns true if this enum value equals Num8
Sourcenum9?
Returns true if this enum value equals Num9
Sourcenum_lock?
Returns true if this enum value equals NumLock
Sourcepage_down?
Returns true if this enum value equals PageDown
Sourcepage_up?
Returns true if this enum value equals PageUp
Sourcepaste_end?
Returns true if this enum value equals PasteEnd
Sourcepaste_start?
Returns true if this enum value equals PasteStart
Sourcepause?
Returns true if this enum value equals Pause
Sourcepercent?
Returns true if this enum value equals Percent
Sourceperiod?
Returns true if this enum value equals Period
Sourcepipe?
Returns true if this enum value equals Pipe
Sourceplus?
Returns true if this enum value equals Plus
Sourceprint_screen?
Returns true if this enum value equals PrintScreen
Sourceprintable?
Returns true if this key produces a printable character.
Sourcequestion?
Returns true if this enum value equals Question
Sourcequote?
Returns true if this enum value equals Quote
Sourceright?
Returns true if this enum value equals Right
Sourceright_brace?
Returns true if this enum value equals RightBrace
Sourceright_bracket?
Returns true if this enum value equals RightBracket
Sourceright_paren?
Returns true if this enum value equals RightParen
Sourcesemicolon?
Returns true if this enum value equals Semicolon
Sourceslash?
Returns true if this enum value equals Slash
Sourcespace?
Returns true if this enum value equals Space
Sourcetab?
Returns true if this enum value equals Tab
Sourcetilde?
Returns true if this enum value equals Tilde
Sourceto_char
Returns the character representation of this key, if printable.
Sourceunderscore?
Returns true if this enum value equals Underscore
Sourceunknown?
Returns true if this enum value equals Unknown
Sourceup?
Returns true if this enum value equals Up
Sourceupper_a?
Returns true if this enum value equals UpperA
Sourceupper_b?
Returns true if this enum value equals UpperB
Sourceupper_c?
Returns true if this enum value equals UpperC
Sourceupper_d?
Returns true if this enum value equals UpperD
Sourceupper_e?
Returns true if this enum value equals UpperE
Sourceupper_f?
Returns true if this enum value equals UpperF
Sourceupper_g?
Returns true if this enum value equals UpperG
Sourceupper_h?
Returns true if this enum value equals UpperH
Sourceupper_i?
Returns true if this enum value equals UpperI
Sourceupper_j?
Returns true if this enum value equals UpperJ
Sourceupper_k?
Returns true if this enum value equals UpperK
Sourceupper_l?
Returns true if this enum value equals UpperL
Sourceupper_m?
Returns true if this enum value equals UpperM
Sourceupper_n?
Returns true if this enum value equals UpperN
Sourceupper_o?
Returns true if this enum value equals UpperO
Sourceupper_p?
Returns true if this enum value equals UpperP
Sourceupper_q?
Returns true if this enum value equals UpperQ
Sourceupper_r?
Returns true if this enum value equals UpperR
Sourceupper_s?
Returns true if this enum value equals UpperS
Sourceupper_t?
Returns true if this enum value equals UpperT
Sourceupper_u?
Returns true if this enum value equals UpperU
Sourceupper_v?
Returns true if this enum value equals UpperV
Sourceupper_w?
Returns true if this enum value equals UpperW
Sourceupper_x?
Returns true if this enum value equals UpperX
Sourceupper_y?
Returns true if this enum value equals UpperY
Sourceupper_z?
Returns true if this enum value equals UpperZ
Source