struct
TermBuf::Key
- TermBuf::Key
- Struct
- Value
- Object
Overview
One key press.
A key is a value: it says which key, which modifiers, and for an ordinary
character which character. What the terminal sent to say so is on the
Events::Key that carries it, since two terminals can send different bytes
for the same key and an application should not have to care.
Modifiers are only as good as the terminal's encoding. Ctrl with a letter
arrives as one control byte, so Ctrl+I and Tab are the same key press
and nothing downstream can separate them. Terminals implementing the kitty
keyboard protocol can, which is why that protocol exists.
Defined in:
termbuf/input/key.crConstructors
-
.character(char : Char, modifiers : Modifiers = Modifiers::None) : Key
An ordinary character key.
-
.named(name : Name, modifiers : Modifiers = Modifiers::None) : Key
A named key.
- .new(name : Name, char : Char = '\0', modifiers : Modifiers = Modifiers::None)
Instance Method Summary
-
#alt? : Bool
Whether alt was held.
-
#char : Char
The character pressed, for a
Characterkey. -
#character? : Bool
Whether this is an ordinary character rather than a named key.
-
#ctrl? : Bool
Whether control was held.
-
#is?(char : Char) : Bool
Whether this is char with no modifiers but shift, which is what asking "did they type a q" means.
-
#is?(name : Name) : Bool
Whether this is the named key, whatever was held down with it.
-
#modifiers : Modifiers
What was held down with it.
-
#name : Name
Which key, with
Name::Charactermeaning the one in#char. -
#shift? : Bool
Whether shift was held.
-
#super? : Bool
Whether the windows, command, or meta key was held.
-
#to_s(io : IO) : Nil
A form suited to a key binding table:
Ctrl+C,Alt+Up,Shift+F5.
Constructor Detail
An ordinary character key.
A named key.
Instance Method Detail
Whether this is char with no modifiers but shift, which is what asking "did they type a q" means.
Whether this is the named key, whatever was held down with it.