Documentation ¶
Overview ¶
Package key defines an event for physical keyboard keys, for the GoGi GUI system.
On-screen software keyboards do not send key events.
Index ¶
- Variables
- func CodeIsModifier(c Codes) bool
- func HasAllModifierBits(modBits int32, mods ...Modifiers) bool
- func HasAnyModifierBits(modBits int32, mods ...Modifiers) bool
- func ModsFmString(cs string) (int32, string)
- func ModsString(mods int32) string
- func SetModifierBits(modBits *int32, mods ...Modifiers)
- type Actions
- type Chord
- type ChordEvent
- type Codes
- type Event
- func (e *Event) Chord() Chord
- func (e *Event) HasAllModifier(mods ...Modifiers) bool
- func (e *Event) HasAnyModifier(mods ...Modifiers) bool
- func (ev *Event) HasPos() bool
- func (ev *Event) OnFocus() bool
- func (ev *Event) Pos() image.Point
- func (e *Event) SetModifiers(mods ...Modifiers)
- func (ev *Event) String() string
- func (ev *Event) Type() oswin.EventType
- type Modifiers
Constants ¶
This section is empty.
Variables ¶
var CodeRuneMap = map[Codes]rune{ CodeA: 'A', CodeB: 'B', CodeC: 'C', CodeD: 'D', CodeE: 'E', CodeF: 'F', CodeG: 'G', CodeH: 'H', CodeI: 'I', CodeJ: 'J', CodeK: 'K', CodeL: 'L', CodeM: 'M', CodeN: 'N', CodeO: 'O', CodeP: 'P', CodeQ: 'Q', CodeR: 'R', CodeS: 'S', CodeT: 'T', CodeU: 'U', CodeV: 'V', CodeW: 'W', CodeX: 'X', CodeY: 'Y', CodeZ: 'Z', Code1: '1', Code2: '2', Code3: '3', Code4: '4', Code5: '5', Code6: '6', Code7: '7', Code8: '8', Code9: '9', Code0: '0', CodeTab: '\t', CodeSpacebar: ' ', CodeHyphenMinus: '-', CodeEqualSign: '=', CodeLeftSquareBracket: '[', CodeRightSquareBracket: ']', CodeBackslash: '\\', CodeSemicolon: ';', CodeApostrophe: '\'', CodeGraveAccent: '`', CodeComma: ',', CodeFullStop: '.', CodeSlash: '/', CodeKeypadSlash: '/', CodeKeypadAsterisk: '*', CodeKeypadHyphenMinus: '-', CodeKeypadPlusSign: '+', CodeKeypadFullStop: '.', CodeKeypadEqualSign: '=', }
var KiT_Actions = kit.Enums.AddEnum(ActionsN, kit.NotBitFlag, nil)
var KiT_Modifiers = kit.Enums.AddEnum(ModifiersN, kit.BitFlag, nil)
Functions ¶
func CodeIsModifier ¶
CodeIsModifier returns true if given code is a modifier key
func HasAllModifierBits ¶
HasAllModifiersBits tests whether all of given modifier(s) bits were set
func HasAnyModifierBits ¶
HasAnyModifierBits tests whether any of given modifier(s) bits were set
func ModsFmString ¶
ModsFmString returns the modifiers corresponding to given string and the remainder of the string after modifiers have been stripped
func ModsString ¶
ModsString returns the string representation of the modifiers
func SetModifierBits ¶
SetModifierBits sets the bitflags based on a list of key.Modifiers
Types ¶
type Actions ¶
type Actions int32
Actions is the action taken on the key
func (*Actions) FromString ¶
type Chord ¶
type Chord string
key.Chord represents the key chord associated with a given key function -- it is linked to the KeyChordEdit in the giv ValueView system so you can just type keys to set key chords.
func (Chord) OSShortcut ¶
OSShortcut translates Command into either Control or Meta depending on platform
type ChordEvent ¶
type ChordEvent struct {
Event
}
key.ChordEvent reports events that are generated only on keyboard release, and that include the full chord information about all the modifier keys that were present when a non-modifier key was released -- these are generally appropriate for most uses
func (*ChordEvent) Type ¶
func (ev *ChordEvent) Type() oswin.EventType
type Codes ¶
type Codes uint32
Codes is the identity of a key relative to a notional "standard" keyboard.
const ( CodeUnknown Codes = 0 CodeA Codes = 4 CodeB Codes = 5 CodeC Codes = 6 CodeD Codes = 7 CodeE Codes = 8 CodeF Codes = 9 CodeG Codes = 10 CodeH Codes = 11 CodeI Codes = 12 CodeJ Codes = 13 CodeK Codes = 14 CodeL Codes = 15 CodeM Codes = 16 CodeN Codes = 17 CodeO Codes = 18 CodeP Codes = 19 CodeQ Codes = 20 CodeR Codes = 21 CodeS Codes = 22 CodeT Codes = 23 CodeU Codes = 24 CodeV Codes = 25 CodeW Codes = 26 CodeX Codes = 27 CodeY Codes = 28 CodeZ Codes = 29 Code1 Codes = 30 Code2 Codes = 31 Code3 Codes = 32 Code4 Codes = 33 Code5 Codes = 34 Code6 Codes = 35 Code7 Codes = 36 Code8 Codes = 37 Code9 Codes = 38 Code0 Codes = 39 CodeReturnEnter Codes = 40 CodeEscape Codes = 41 CodeDeleteBackspace Codes = 42 CodeTab Codes = 43 CodeSpacebar Codes = 44 CodeHyphenMinus Codes = 45 // - CodeEqualSign Codes = 46 // = CodeLeftSquareBracket Codes = 47 // [ CodeRightSquareBracket Codes = 48 // ] CodeBackslash Codes = 49 // \ CodeSemicolon Codes = 51 // ; CodeApostrophe Codes = 52 // ' CodeGraveAccent Codes = 53 // ` CodeComma Codes = 54 // , CodeFullStop Codes = 55 // . CodeSlash Codes = 56 // / CodeCapsLock Codes = 57 CodeF1 Codes = 58 CodeF2 Codes = 59 CodeF3 Codes = 60 CodeF4 Codes = 61 CodeF5 Codes = 62 CodeF6 Codes = 63 CodeF7 Codes = 64 CodeF8 Codes = 65 CodeF9 Codes = 66 CodeF10 Codes = 67 CodeF11 Codes = 68 CodeF12 Codes = 69 CodePause Codes = 72 CodeInsert Codes = 73 CodeHome Codes = 74 CodePageUp Codes = 75 CodeDeleteForward Codes = 76 CodeEnd Codes = 77 CodePageDown Codes = 78 CodeRightArrow Codes = 79 CodeLeftArrow Codes = 80 CodeDownArrow Codes = 81 CodeUpArrow Codes = 82 CodeKeypadNumLock Codes = 83 CodeKeypadSlash Codes = 84 // / CodeKeypadAsterisk Codes = 85 // * CodeKeypadHyphenMinus Codes = 86 // - CodeKeypadPlusSign Codes = 87 // + CodeKeypadEnter Codes = 88 CodeKeypad1 Codes = 89 CodeKeypad2 Codes = 90 CodeKeypad3 Codes = 91 CodeKeypad4 Codes = 92 CodeKeypad5 Codes = 93 CodeKeypad6 Codes = 94 CodeKeypad7 Codes = 95 CodeKeypad8 Codes = 96 CodeKeypad9 Codes = 97 CodeKeypad0 Codes = 98 CodeKeypadFullStop Codes = 99 // . CodeKeypadEqualSign Codes = 103 // = CodeF13 Codes = 104 CodeF14 Codes = 105 CodeF15 Codes = 106 CodeF16 Codes = 107 CodeF17 Codes = 108 CodeF18 Codes = 109 CodeF19 Codes = 110 CodeF20 Codes = 111 CodeF21 Codes = 112 CodeF22 Codes = 113 CodeF23 Codes = 114 CodeF24 Codes = 115 CodeHelp Codes = 117 CodeMute Codes = 127 CodeVolumeUp Codes = 128 CodeVolumeDown Codes = 129 CodeLeftControl Codes = 224 CodeLeftShift Codes = 225 CodeLeftAlt Codes = 226 CodeLeftMeta Codes = 227 // Command on mac, win key on windows, ? on linux CodeRightControl Codes = 228 CodeRightShift Codes = 229 CodeRightAlt Codes = 230 CodeRightMeta Codes = 231 // CodeCompose is the Code for a compose key, sometimes called a multi key, // used to input non-ASCII characters such as ñ being composed of n and ~. // // See https://en.wikipedia.org/wiki/Compose_key CodeCompose Codes = 0x10000 )
Physical key codes.
For standard key codes, its value matches USB HID key codes. TODO: add missing codes.
type Event ¶
type Event struct { oswin.EventBase // Rune is the meaning of the key event as determined by the // operating system. The mapping is determined by system-dependent // current layout, modifiers, lock-states, etc. // // If non-negative, it is a Unicode codepoint: pressing the 'a' key // generates different Runes 'a' or 'A' (but the same Code) depending on // the state of the shift key. // // If -1, the key does not generate a Unicode codepoint. To distinguish // them, look at Code. Rune rune // Code is the identity of the physical key relative to a notional // "standard" keyboard, independent of current layout, modifiers, // lock-states, etc // // For standard key codes, its value matches USB HID key codes. // Compare its value to uint32-typed constants in this package, such // as CodeLeftShift and CodeEscape. // // Pressing the regular '2' key and number-pad '2' key (with Num-Lock) // generate different Codes (but the same Rune). Code Codes // Modifiers is bitflags representing a set of modifier keys: ModShift, // ModAlt, etc. -- bit positions are key.Modifiers Modifiers int32 // Action is the key action taken: Press, Release, or None (for key repeats). Action Actions }
key.Event is a low-level immediately-generated key event, tracking press and release of keys -- suitable for fine-grained tracking of key events -- see also key.ChordEvent for events that are generated only on key press, and that include the full chord information about all the modifier keys that were present when a non-modifier key was released
func (*Event) Chord ¶
Chord returns a string representation of the keyboard event suitable for keyboard function maps, etc -- printable runes are sent directly, and non-printable ones are converted to their corresponding code names without the "Code" prefix.
func (*Event) HasAllModifier ¶
HasAllModifiers tests whether all of given modifier(s) were set
func (*Event) HasAnyModifier ¶
HasAnyModifier tests whether any of given modifier(s) were set
func (*Event) SetModifiers ¶
SetModifiers sets the bitflags based on a list of key.Modifiers
type Modifiers ¶
type Modifiers int32
Modifiers are used as bitflags representing a set of modifier keys -- see SetModifiers method