KeyEvent

Table of contents

Represent a keyboard event

type KeyEvent struct {
    AltKey bool
    Code KeyCode
    CtrlKey bool
    Key string
    MetaKey bool
    Repeat bool
    ShiftKey bool
    TimeStamp uint64
}
Member Type Description
AltKey bool true if the alt key was down when the event was fired, false otherwise
Code KeyCode String that identifies the physical key being pressed. The value is not affected by the current keyboard layout or modifier state, so a particular key will always return the same value.
CtrlKey bool true if the control key was down when the event was fired. false otherwise.
Key string Key value of the key represented by the event. If the value has a printed representation, this attribute's value is the same as the char property. Otherwise, it's one of the key value strings specified in Key values. If the key can't be identified, its value is the string "Unidentified".
MetaKey bool true if the meta key was down when the event was fired. false otherwise.
Repeat bool true if a key has been depressed long enough to trigger key repetition, otherwise false.
ShiftKey bool true if the shift key was down when the event was fired. false otherwise.
TimeStamp uint64 Time at which the event was created (in milliseconds). This value is time since epoch—but in reality, browsers' definitions vary.

Key codes used by the library:

Value Constant Description
"KeyA" KeyA Represent "A" key on the keyboard
"KeyB" KeyB Represent "B" key on the keyboard
"KeyC" KeyC Represent "C" key on the keyboard
"KeyD" KeyD Represent "D" key on the keyboard
"KeyE" KeyE Represent "E" key on the keyboard
"KeyF" KeyF Represent "F" key on the keyboard
"KeyG" KeyG Represent "G" key on the keyboard
"KeyH" KeyH Represent "H" key on the keyboard
"KeyI" KeyI Represent "I" key on the keyboard
"KeyJ" KeyJ Represent "J" key on the keyboard
"KeyK" KeyK Represent "K" key on the keyboard
"KeyL" KeyL Represent "L" key on the keyboard
"KeyM" KeyM Represent "M" key on the keyboard
"KeyN" KeyN Represent "N" key on the keyboard
"KeyO" KeyO Represent "O" key on the keyboard
"KeyP" KeyP Represent "P" key on the keyboard
"KeyQ" KeyQ Represent "Q" key on the keyboard
"KeyR" KeyR Represent "R" key on the keyboard
"KeyS" KeyS Represent "S" key on the keyboard
"KeyT" KeyT Represent "T" key on the keyboard
"KeyU" KeyU Represent "U" key on the keyboard
"KeyV" KeyV Represent "V" key on the keyboard
"KeyW" KeyW Represent "W" key on the keyboard
"KeyX" KeyX Represent "X" key on the keyboard
"KeyY" KeyY Represent "Y" key on the keyboard
"KeyZ" KeyZ Represent "Z" key on the keyboard
"Digit0" Digit0Key Represent "Digit0" key on the keyboard
"Digit1" Digit1Key Represent "Digit1" key on the keyboard
"Digit2" Digit2Key Represent "Digit2" key on the keyboard
"Digit3" Digit3Key Represent "Digit3" key on the keyboard
"Digit4" Digit4Key Represent "Digit4" key on the keyboard
"Digit5" Digit5Key Represent "Digit5" key on the keyboard
"Digit6" Digit6Key Represent "Digit6" key on the keyboard
"Digit7" Digit7Key Represent "Digit7" key on the keyboard
"Digit8" Digit8Key Represent "Digit8" key on the keyboard
"Digit9" Digit9Key Represent "Digit9" key on the keyboard
"Space" SpaceKey Represent "Space" key on the keyboard
"Minus" MinusKey Represent "Minus" key on the keyboard
"Equal" EqualKey Represent "Equal" key on the keyboard
"IntlBackslash" IntlBackslashKey Represent "IntlBackslash" key on the keyboard
"BracketLeft" BracketLeftKey Represent "BracketLeft" key on the keyboard
"BracketRight" BracketRightKey Represent "BracketRight" key on the keyboard
"Semicolon" SemicolonKey Represent "Semicolon" key on the keyboard
"Comma" CommaKey Represent "Comma" key on the keyboard
"Period" PeriodKey Represent "Period" key on the keyboard
"Quote" QuoteKey Represent "Quote" key on the keyboard
"Backquote" BackquoteKey Represent "Backquote" key on the keyboard
"Slash" SlashKey Represent "Slash" key on the keyboard
"Escape" EscapeKey Represent "Escape" key on the keyboard
"Enter" EnterKey Represent "Enter" key on the keyboard
"Tab" TabKey Represent "Tab" key on the keyboard
"CapsLock" CapsLockKey Represent "CapsLock" key on the keyboard
"Delete" DeleteKey Represent "Delete" key on the keyboard
"Insert" InsertKey Represent "Insert" key on the keyboard
"Help" HelpKey Represent "Help" key on the keyboard
"Backspace" BackspaceKey Represent "Backspace" key on the keyboard
"PrintScreen" PrintScreenKey Represent "PrintScreen" key on the keyboard
"ScrollLock" ScrollLockKey Represent "ScrollLock" key on the keyboard
"Pause" PauseKey Represent "Pause" key on the keyboard
"ContextMenu" ContextMenuKey Represent "ContextMenu" key on the keyboard
"ArrowLeft" ArrowLeftKey Represent "ArrowLeft" key on the keyboard
"ArrowRight" ArrowRightKey Represent "ArrowRight" key on the keyboard
"ArrowUp" ArrowUpKey Represent "ArrowUp" key on the keyboard
"ArrowDown" ArrowDownKey Represent "ArrowDown" key on the keyboard
"Home" HomeKey Represent "Home" key on the keyboard
"End" EndKey Represent "End" key on the keyboard
"PageUp" PageUpKey Represent "PageUp" key on the keyboard
"PageDown" PageDownKey Represent "PageDown" key on the keyboard
"F1" F1Key Represent "F1" key on the keyboard
"F2" F2Key Represent "F2" key on the keyboard
"F3" F3Key Represent "F3" key on the keyboard
"F4" F4Key Represent "F4" key on the keyboard
"F5" F5Key Represent "F5" key on the keyboard
"F6" F6Key Represent "F6" key on the keyboard
"F7" F7Key Represent "F7" key on the keyboard
"F8" F8Key Represent "F8" key on the keyboard
"F9" F9Key Represent "F9" key on the keyboard
"F10" F10Key Represent "F10" key on the keyboard
"F11" F11Key Represent "F11" key on the keyboard
"F12" F12Key Represent "F12" key on the keyboard
"F13" F13Key Represent "F13" key on the keyboard
"NumLock" NumLockKey Represent "NumLock" key on the keyboard
"Numpad0" NumpadKey0 Represent "Numpad0" key on the keyboard
"Numpad1" NumpadKey1 Represent "Numpad1" key on the keyboard
"Numpad2" NumpadKey2 Represent "Numpad2" key on the keyboard
"Numpad3" NumpadKey3 Represent "Numpad3" key on the keyboard
"Numpad4" NumpadKey4 Represent "Numpad4" key on the keyboard
"Numpad5" NumpadKey5 Represent "Numpad5" key on the keyboard
"Numpad6" NumpadKey6 Represent "Numpad6" key on the keyboard
"Numpad7" NumpadKey7 Represent "Numpad7" key on the keyboard
"Numpad8" NumpadKey8 Represent "Numpad8" key on the keyboard
"Numpad9" NumpadKey9 Represent "Numpad9" key on the keyboard
"NumpadDecimal" NumpadDecimalKey Represent "NumpadDecimal" key on the keyboard
"NumpadEnter" NumpadEnterKey Represent "NumpadEnter" key on the keyboard
"NumpadAdd" NumpadAddKey Represent "NumpadAdd" key on the keyboard
"NumpadSubtract" NumpadSubtractKey Represent "NumpadSubtract" key on the keyboard
"NumpadMultiply" NumpadMultiplyKey Represent "NumpadMultiply" key on the keyboard
"NumpadDivide" NumpadDivideKey Represent "NumpadDivide" key on the keyboard
"ShiftLeft" ShiftLeftKey Represent "ShiftLeft" key on the keyboard
"ShiftRight" ShiftRightKey Represent "ShiftRight" key on the keyboard
"ControlLeft" ControlLeftKey Represent "ControlLeft" key on the keyboard
"ControlRight" ControlRightKey Represent "ControlRight" key on the keyboard
"AltLeft" AltLeftKey Represent "AltLeft" key on the keyboard
"AltRight" AltRightKey Represent "AltRight" key on the keyboard
"MetaLeft" MetaLeftKey Represent "MetaLeft" key on the keyboard
"MetaRight" MetaRightKey Represent "MetaRight" key on the keyboard
func GetKeyDownListeners(view View, subviewID ...string) []func(View, KeyEvent)

Returns the "key-down-event" listener list. If there are no listeners then the empty list is returned. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func GetKeyUpListeners(view View, subviewID ...string) []func(View, KeyEvent)

Returns the "key-up-event" listener list. If there are no listeners then the empty list is returned. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned