Documentation ¶
Index ¶
Constants ¶
const ( KeyEnter = Key(300) KeyEscape = Key(301) KeyBackspace = Key(302) KeyTab = Key(303) KeyDown = Key(310) KeyLeft = Key(311) KeyRight = Key(312) KeyUp = Key(313) KeyDelete = Key(320) KeyEnd = Key(321) KeyHome = Key(322) KeyInsert = Key(323) KeyPageDown = Key(324) KeyPageUp = Key(325) KeyAlt = Key(330) KeyControl = Key(331) KeyShift = Key(332) KeySuper = Key(333) KeyPause = Key(340) KeyPrintScreen = Key(341) KeyCapsLock = Key(342) KeyScrollLock = Key(343) KeyF1 = Key(351) KeyF10 = Key(360) KeyF11 = Key(361) KeyF12 = Key(362) KeyF13 = Key(363) KeyF14 = Key(364) KeyF15 = Key(365) KeyF16 = Key(366) KeyF17 = Key(367) KeyF18 = Key(368) KeyF19 = Key(369) KeyF2 = Key(352) KeyF20 = Key(370) KeyF21 = Key(371) KeyF22 = Key(372) KeyF23 = Key(373) KeyF24 = Key(374) KeyF25 = Key(375) KeyF3 = Key(353) KeyF4 = Key(354) KeyF5 = Key(355) KeyF6 = Key(356) KeyF7 = Key(357) KeyF8 = Key(358) KeyF9 = Key(359) KeyCopy = Key(380) KeyCut = Key(381) KeyPaste = Key(382) KeyUndo = Key(390) KeyRedo = Key(391) KeySave = Key(400) KeyNew = Key(401) KeyA = Key(410) KeyC = Key(411) KeyV = Key(412) KeyX = Key(413) )
Constants for commonly known named keys.
const ( ModNone = Modifier(0x00000000) ModShift = Modifier(0x00000001) ModControl = Modifier(0x00000002) ModAlt = Modifier(0x00000004) ModSuper = Modifier(0x00000008) )
Constants for common modifier.
const ( // MousePrimary specifies the primary mouse button (by default, the left one). MousePrimary = uint32(1) // MouseSecondary specifies the secondary mouse button (by default, the right one). MouseSecondary = uint32(2) )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Key ¶
type Key int
Key describes a named key on the keyboard. These are keys which are unspecific to layout or language, or are universal. Or, described in another way: keys that don't end up as printable characters.
func ResolveShortcut ¶
ResolveShortcut tries to map the given name and modifier combination to a known (common) shortcut key. For instance, Ctrl+C is KeyCopy.
func (Key) AsModifier ¶
AsModifier returns the modifier equivalent for the key - if applicable.
type Modifier ¶
type Modifier uint32
Modifier is a collection of currently pressed modifier keys.
func (Modifier) Has ¶
Has returns true if the given modifier is included in this set. This modifier can have more keys set than the requested and still return true.
type StickyKeyBuffer ¶
type StickyKeyBuffer struct {
// contains filtered or unexported fields
}
StickyKeyBuffer is a buffer to keep track of several identically named keys. Keys can be reported being pressed or released. Their state will be forwarded to a StickyKeyListener instance. If a specific key is reported to be pressed more than once, the listener will have received the down state only once.
func NewStickyKeyBuffer ¶
func NewStickyKeyBuffer(listener StickyKeyListener) *StickyKeyBuffer
NewStickyKeyBuffer returns a new instance of a sticky key buffer.
func (*StickyKeyBuffer) ActiveModifier ¶
func (buffer *StickyKeyBuffer) ActiveModifier() Modifier
ActiveModifier returns the currently pressed modifier set.
func (*StickyKeyBuffer) KeyDown ¶
func (buffer *StickyKeyBuffer) KeyDown(key Key, modifier Modifier)
KeyDown registers a pressed key state. Multiple down states can be registered for the same key and result in only one key event.
func (*StickyKeyBuffer) KeyUp ¶
func (buffer *StickyKeyBuffer) KeyUp(key Key, modifier Modifier)
KeyUp registers a released key state. Multiple up states can be registered for the same key, as long as enough down states were reported.
func (*StickyKeyBuffer) ReleaseAll ¶
func (buffer *StickyKeyBuffer) ReleaseAll()
ReleaseAll notifies the listener of the reset of all modifiers. Key states are reset to accept new down states.
type StickyKeyListener ¶
type StickyKeyListener interface { // KeyPress is called for a pressed key. KeyPress(key Key, modifier Modifier) // KeyRelease is called for a released key. KeyRelease(key Key, modifier Modifier) // Modifier is called when the currently active modifier changed. Modifier(modifier Modifier) }
StickyKeyListener is the listener interface for receiving key events.