zntg/ui/key.go

158 lines
1.7 KiB
Go
Raw Permalink Normal View History

package ui
type Key int
const (
KeyNone Key = iota
Key0
Key1
Key2
Key3
Key4
Key5
Key6
Key7
Key8
Key9
KeyA
KeyAlt
KeyAltGr
KeyAt
KeyB
KeyBack
KeyBackslash //x2
KeyBackspace
KeyBacktick
KeyButtonA
KeyButtonB
KeyButtonL1
KeyButtonL2
KeyButtonR1
KeyButtonR2
KeyButtonX
KeyButtonY
KeyC
KeyCapsLock
KeyCircumflex
KeyCloseBrace
KeyColon2
KeyComma
KeyCommand
KeyD
KeyDelete
KeyDown
KeyDPadCenter
KeyDPadDown
KeyDPadLeft
KeyDPadRight
KeyDPadUp
KeyE
KeyEnd
KeyEnter
KeyEquals
KeyEscape
KeyF
KeyF1
KeyF2
KeyF3
KeyF4
KeyF5
KeyF6
KeyF7
KeyF8
KeyF9
KeyF10
KeyF11
KeyF12
KeyFullstop
KeyG
KeyH
KeyHome
KeyI
KeyInsert
KeyJ
KeyK
KeyL
KeyLeft
KeyLeftControl
KeyLeftShift
KeyLeftWin
KeyM
KeyMenu
KeyMinus
KeyN
KeyNumLock
KeyO
KeyOpenBrace
KeyP
KeyPad0
KeyPad1
KeyPad2
KeyPad3
KeyPad4
KeyPad5
KeyPad6
KeyPad7
KeyPad8
KeyPad9
KeyPadAsterisk
KeyPadDelete
KeyPadEnter
KeyPadEquals
KeyPadMinus
KeyPadPlus
KeyPadSlash
KeyPageDown
KeyPageUp
KeyPause
KeyPrintScreen
KeyQ
KeyQuote
KeyR
KeyRight
KeyRightControl
KeyRightShift
KeyRightWin
KeyS
KeyScrollLock
KeySearch
KeySelect
KeySemicolon
KeySlash
KeySpace
KeyStart
KeyT
KeyTab
KeyThumbL
KeyThumbR
KeyTilde
KeyU
KeyUp
KeyV
KeyVolumeDown
KeyVolumeUp
KeyW
KeyX
KeyY
KeyZ
)
type KeyState map[Key]bool
func (s KeyState) Modifiers() KeyModifier {
var mods KeyModifier
if s[KeyAlt] || s[KeyAltGr] {
mods |= KeyModifierAlt
}
if s[KeyLeftControl] || s[KeyRightControl] {
mods |= KeyModifierControl
}
if s[KeyLeftShift] || s[KeyRightShift] {
mods |= KeyModifierShift
}
if s[KeyLeftWin] || s[KeyRightWin] || s[KeyCommand] {
mods |= KeyModifierOSCommand
}
return mods
}