2020-07-07 01:26:08 +00:00
|
|
|
package d2enum
|
2020-06-23 22:12:08 +00:00
|
|
|
|
2020-07-01 18:03:40 +00:00
|
|
|
// Key represents button on a traditional keyboard.
|
2020-06-23 22:12:08 +00:00
|
|
|
type Key int
|
|
|
|
|
2020-11-02 03:43:23 +00:00
|
|
|
// GetString returns a string representing the key
|
|
|
|
func (k Key) GetString() string {
|
|
|
|
switch k {
|
|
|
|
case -1:
|
|
|
|
return "None"
|
|
|
|
case KeyControl:
|
|
|
|
return "Ctrl"
|
|
|
|
case KeyShift:
|
|
|
|
return "Shift"
|
|
|
|
case KeySpace:
|
|
|
|
return "Space"
|
|
|
|
case KeyAlt:
|
|
|
|
return "Alt"
|
|
|
|
case KeyTab:
|
|
|
|
return "Tab"
|
|
|
|
case KeyH:
|
|
|
|
return "H"
|
|
|
|
default:
|
|
|
|
return "Unknown"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Input keys
|
2020-06-23 22:12:08 +00:00
|
|
|
const (
|
|
|
|
Key0 Key = iota
|
|
|
|
Key1
|
|
|
|
Key2
|
|
|
|
Key3
|
|
|
|
Key4
|
|
|
|
Key5
|
|
|
|
Key6
|
|
|
|
Key7
|
|
|
|
Key8
|
|
|
|
Key9
|
|
|
|
KeyA
|
|
|
|
KeyB
|
|
|
|
KeyC
|
|
|
|
KeyD
|
|
|
|
KeyE
|
|
|
|
KeyF
|
|
|
|
KeyG
|
|
|
|
KeyH
|
|
|
|
KeyI
|
|
|
|
KeyJ
|
|
|
|
KeyK
|
|
|
|
KeyL
|
|
|
|
KeyM
|
|
|
|
KeyN
|
|
|
|
KeyO
|
|
|
|
KeyP
|
|
|
|
KeyQ
|
|
|
|
KeyR
|
|
|
|
KeyS
|
|
|
|
KeyT
|
|
|
|
KeyU
|
|
|
|
KeyV
|
|
|
|
KeyW
|
|
|
|
KeyX
|
|
|
|
KeyY
|
|
|
|
KeyZ
|
|
|
|
KeyApostrophe
|
|
|
|
KeyBackslash
|
|
|
|
KeyBackspace
|
|
|
|
KeyCapsLock
|
|
|
|
KeyComma
|
|
|
|
KeyDelete
|
|
|
|
KeyDown
|
|
|
|
KeyEnd
|
|
|
|
KeyEnter
|
|
|
|
KeyEqual
|
|
|
|
KeyEscape
|
|
|
|
KeyF1
|
|
|
|
KeyF2
|
|
|
|
KeyF3
|
|
|
|
KeyF4
|
|
|
|
KeyF5
|
|
|
|
KeyF6
|
|
|
|
KeyF7
|
|
|
|
KeyF8
|
|
|
|
KeyF9
|
|
|
|
KeyF10
|
|
|
|
KeyF11
|
|
|
|
KeyF12
|
|
|
|
KeyGraveAccent
|
|
|
|
KeyHome
|
|
|
|
KeyInsert
|
|
|
|
KeyKP0
|
|
|
|
KeyKP1
|
|
|
|
KeyKP2
|
|
|
|
KeyKP3
|
|
|
|
KeyKP4
|
|
|
|
KeyKP5
|
|
|
|
KeyKP6
|
|
|
|
KeyKP7
|
|
|
|
KeyKP8
|
|
|
|
KeyKP9
|
|
|
|
KeyKPAdd
|
|
|
|
KeyKPDecimal
|
|
|
|
KeyKPDivide
|
|
|
|
KeyKPEnter
|
|
|
|
KeyKPEqual
|
|
|
|
KeyKPMultiply
|
|
|
|
KeyKPSubtract
|
|
|
|
KeyLeft
|
|
|
|
KeyLeftBracket
|
|
|
|
KeyMenu
|
|
|
|
KeyMinus
|
|
|
|
KeyNumLock
|
|
|
|
KeyPageDown
|
|
|
|
KeyPageUp
|
|
|
|
KeyPause
|
|
|
|
KeyPeriod
|
|
|
|
KeyPrintScreen
|
|
|
|
KeyRight
|
|
|
|
KeyRightBracket
|
|
|
|
KeyScrollLock
|
|
|
|
KeySemicolon
|
|
|
|
KeySlash
|
|
|
|
KeySpace
|
|
|
|
KeyTab
|
|
|
|
KeyUp
|
|
|
|
KeyAlt
|
|
|
|
KeyControl
|
|
|
|
KeyShift
|
2020-11-02 03:43:23 +00:00
|
|
|
KeyTilde
|
2020-06-23 22:12:08 +00:00
|
|
|
|
2020-07-03 19:09:16 +00:00
|
|
|
KeyMin = Key0
|
|
|
|
KeyMax = KeyShift
|
2020-06-23 22:12:08 +00:00
|
|
|
)
|
|
|
|
|
2020-07-01 18:03:40 +00:00
|
|
|
// KeyMod represents a "modified" key action. This could mean, for example, ctrl-S
|
2020-06-23 22:12:08 +00:00
|
|
|
type KeyMod int
|
|
|
|
|
|
|
|
const (
|
2020-07-01 18:03:40 +00:00
|
|
|
// KeyModAlt is the Alt key modifier
|
2020-06-23 22:12:08 +00:00
|
|
|
KeyModAlt KeyMod = 1 << iota
|
2020-07-01 18:03:40 +00:00
|
|
|
// KeyModControl is the Control key modifier
|
2020-06-23 22:12:08 +00:00
|
|
|
KeyModControl
|
2020-07-01 18:03:40 +00:00
|
|
|
// KeyModShift is the Shift key modifier
|
2020-06-23 22:12:08 +00:00
|
|
|
KeyModShift
|
|
|
|
)
|