mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
ebiten: Change the key name convention to follow the Web standard
Closes #1394
This commit is contained in:
parent
4c22314b3a
commit
4398a5e227
443
genkeys.go
443
genkeys.go
@ -14,10 +14,7 @@
|
||||
|
||||
// +build ignore
|
||||
|
||||
// Note:
|
||||
// * Respect GLFW key names
|
||||
// * https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.keyCode
|
||||
// * It is best to replace keyCode with code, but many browsers don't implement it.
|
||||
// The key name convention follows the Web standard: https://www.w3.org/TR/uievents-code/#keyboard-key-codes
|
||||
|
||||
package main
|
||||
|
||||
@ -35,11 +32,13 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
glfwKeyNameToGLFWKey map[string]glfw.Key
|
||||
androidKeyToDriverKeyName map[int]string
|
||||
gbuildKeyToDriverKeyName map[key.Code]string
|
||||
driverKeyNameToJSKey map[string]string
|
||||
edgeKeyCodeToName map[int]string
|
||||
glfwKeyNameToGLFWKey map[string]glfw.Key
|
||||
driverKeyNameToGLFWKeyName map[string]string
|
||||
androidKeyToDriverKeyName map[int]string
|
||||
gbuildKeyToDriverKeyName map[key.Code]string
|
||||
driverKeyNameToJSKey map[string]string
|
||||
edgeKeyCodeToName map[int]string
|
||||
oldEbitenKeyNameToDriverKeyName map[string]string
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -97,17 +96,67 @@ func init() {
|
||||
"Last": glfw.KeyLast,
|
||||
}
|
||||
|
||||
driverKeyNameToGLFWKeyName = map[string]string{
|
||||
"Space": "Space",
|
||||
"Quote": "Apostrophe",
|
||||
"Comma": "Comma",
|
||||
"Minus": "Minus",
|
||||
"Period": "Period",
|
||||
"Slash": "Slash",
|
||||
"Semicolon": "Semicolon",
|
||||
"Equal": "Equal",
|
||||
"BracketLeft": "LeftBracket",
|
||||
"Backslash": "Backslash",
|
||||
"BracketRight": "RightBracket",
|
||||
"Backquote": "GraveAccent",
|
||||
"Escape": "Escape",
|
||||
"Enter": "Enter",
|
||||
"Tab": "Tab",
|
||||
"Backspace": "Backspace",
|
||||
"Insert": "Insert",
|
||||
"Delete": "Delete",
|
||||
"ArrowRight": "Right",
|
||||
"ArrowLeft": "Left",
|
||||
"ArrowDown": "Down",
|
||||
"ArrowUp": "Up",
|
||||
"PageUp": "PageUp",
|
||||
"PageDown": "PageDown",
|
||||
"Home": "Home",
|
||||
"End": "End",
|
||||
"CapsLock": "CapsLock",
|
||||
"ScrollLock": "ScrollLock",
|
||||
"NumLock": "NumLock",
|
||||
"PrintScreen": "PrintScreen",
|
||||
"Pause": "Pause",
|
||||
"ShiftLeft": "LeftShift",
|
||||
"ControlLeft": "LeftControl",
|
||||
"AltLeft": "LeftAlt",
|
||||
"MetaLeft": "LeftSuper",
|
||||
"ShiftRight": "RightShift",
|
||||
"ControlRight": "RightControl",
|
||||
"AltRight": "RightAlt",
|
||||
"MetaRight": "RightSuper",
|
||||
"ContextMenu": "Menu",
|
||||
"NumpadAdd": "KPAdd",
|
||||
"NumpadDecimal": "KPDecimal",
|
||||
"NumpadDivide": "KPDivide",
|
||||
"NumpadMultiply": "KPMultiply",
|
||||
"NumpadSubtract": "KPSubtract",
|
||||
"NumpadEnter": "KPEnter",
|
||||
"NumpadEqual": "KPEqual",
|
||||
}
|
||||
|
||||
// https://developer.android.com/reference/android/view/KeyEvent
|
||||
androidKeyToDriverKeyName = map[int]string{
|
||||
55: "Comma",
|
||||
56: "Period",
|
||||
57: "LeftAlt",
|
||||
58: "RightAlt",
|
||||
57: "AltLeft",
|
||||
58: "AltRight",
|
||||
115: "CapsLock",
|
||||
113: "LeftControl",
|
||||
114: "RightControl",
|
||||
59: "LeftShift",
|
||||
60: "RightShift",
|
||||
113: "ControlLeft",
|
||||
114: "ControlRight",
|
||||
59: "ShiftLeft",
|
||||
60: "ShiftRight",
|
||||
66: "Enter",
|
||||
62: "Space",
|
||||
61: "Tab",
|
||||
@ -117,47 +166,47 @@ func init() {
|
||||
124: "Insert",
|
||||
93: "PageDown",
|
||||
92: "PageUp",
|
||||
20: "Down",
|
||||
21: "Left",
|
||||
22: "Right",
|
||||
19: "Up",
|
||||
20: "ArrowDown",
|
||||
21: "ArrowLeft",
|
||||
22: "ArrowRight",
|
||||
19: "ArrowUp",
|
||||
111: "Escape",
|
||||
67: "Backspace", // KEYCODE_DEL
|
||||
75: "Apostrophe",
|
||||
75: "Quote",
|
||||
69: "Minus",
|
||||
76: "Slash",
|
||||
74: "Semicolon",
|
||||
70: "Equal",
|
||||
71: "LeftBracket",
|
||||
71: "BracketLeft",
|
||||
73: "Backslash",
|
||||
72: "RightBracket",
|
||||
68: "GraveAccent",
|
||||
72: "BracketRight",
|
||||
68: "Backquote",
|
||||
143: "NumLock",
|
||||
121: "Pause", // KEYCODE_BREAK
|
||||
120: "PrintScreen", // KEYCODE_SYSRQ
|
||||
116: "ScrollLock",
|
||||
82: "Menu",
|
||||
158: "KPDecimal",
|
||||
154: "KPDivide",
|
||||
155: "KPMultiply",
|
||||
156: "KPSubtract",
|
||||
157: "KPAdd",
|
||||
160: "KPEnter",
|
||||
161: "KPEqual",
|
||||
117: "LeftSuper", // KEYCODE_META_LEFT
|
||||
118: "RightSuper", // KEYCODE_META_RIGHT
|
||||
82: "ContextMenu",
|
||||
157: "NumpadAdd",
|
||||
158: "NumpadDecimal",
|
||||
154: "NumpadDivide",
|
||||
155: "NumpadMultiply",
|
||||
156: "NumpadSubtract",
|
||||
160: "NumpadEnter",
|
||||
161: "NumpadEqual",
|
||||
117: "MetaLeft",
|
||||
118: "MetaRight",
|
||||
}
|
||||
|
||||
gbuildKeyToDriverKeyName = map[key.Code]string{
|
||||
key.CodeComma: "Comma",
|
||||
key.CodeFullStop: "Period",
|
||||
key.CodeLeftAlt: "LeftAlt",
|
||||
key.CodeRightAlt: "RightAlt",
|
||||
key.CodeLeftAlt: "AltLeft",
|
||||
key.CodeRightAlt: "AltRight",
|
||||
key.CodeCapsLock: "CapsLock",
|
||||
key.CodeLeftControl: "LeftControl",
|
||||
key.CodeRightControl: "RightControl",
|
||||
key.CodeLeftShift: "LeftShift",
|
||||
key.CodeRightShift: "RightShift",
|
||||
key.CodeLeftControl: "ControlLeft",
|
||||
key.CodeRightControl: "ControlRight",
|
||||
key.CodeLeftShift: "ShiftLeft",
|
||||
key.CodeRightShift: "ShiftRight",
|
||||
key.CodeReturnEnter: "Enter",
|
||||
key.CodeSpacebar: "Space",
|
||||
key.CodeTab: "Tab",
|
||||
@ -167,32 +216,32 @@ func init() {
|
||||
key.CodeInsert: "Insert",
|
||||
key.CodePageDown: "PageDown",
|
||||
key.CodePageUp: "PageUp",
|
||||
key.CodeDownArrow: "Down",
|
||||
key.CodeLeftArrow: "Left",
|
||||
key.CodeRightArrow: "Right",
|
||||
key.CodeUpArrow: "Up",
|
||||
key.CodeDownArrow: "ArrowDown",
|
||||
key.CodeLeftArrow: "ArrowLeft",
|
||||
key.CodeRightArrow: "ArrowRight",
|
||||
key.CodeUpArrow: "ArrowUp",
|
||||
key.CodeEscape: "Escape",
|
||||
key.CodeDeleteBackspace: "Backspace",
|
||||
key.CodeApostrophe: "Apostrophe",
|
||||
key.CodeApostrophe: "Quote",
|
||||
key.CodeHyphenMinus: "Minus",
|
||||
key.CodeSlash: "Slash",
|
||||
key.CodeSemicolon: "Semicolon",
|
||||
key.CodeEqualSign: "Equal",
|
||||
key.CodeLeftSquareBracket: "LeftBracket",
|
||||
key.CodeLeftSquareBracket: "BracketLeft",
|
||||
key.CodeBackslash: "Backslash",
|
||||
key.CodeRightSquareBracket: "RightBracket",
|
||||
key.CodeGraveAccent: "GraveAccent",
|
||||
key.CodeRightSquareBracket: "BracketRight",
|
||||
key.CodeGraveAccent: "Backquote",
|
||||
key.CodeKeypadNumLock: "NumLock",
|
||||
key.CodePause: "Pause",
|
||||
key.CodeKeypadFullStop: "KPDecimal",
|
||||
key.CodeKeypadSlash: "KPDivide",
|
||||
key.CodeKeypadAsterisk: "KPMultiply",
|
||||
key.CodeKeypadHyphenMinus: "KPSubtract",
|
||||
key.CodeKeypadPlusSign: "KPAdd",
|
||||
key.CodeKeypadEnter: "KPEnter",
|
||||
key.CodeKeypadEqualSign: "KPEqual",
|
||||
key.CodeLeftGUI: "LeftSuper",
|
||||
key.CodeRightGUI: "RightSuper",
|
||||
key.CodeKeypadPlusSign: "NumpadAdd",
|
||||
key.CodeKeypadFullStop: "NumpadDecimal",
|
||||
key.CodeKeypadSlash: "NumpadDivide",
|
||||
key.CodeKeypadAsterisk: "NumpadMultiply",
|
||||
key.CodeKeypadHyphenMinus: "NumpadSubtract",
|
||||
key.CodeKeypadEnter: "NumpadEnter",
|
||||
key.CodeKeypadEqualSign: "NumpadEqual",
|
||||
key.CodeLeftGUI: "MetaLeft",
|
||||
key.CodeRightGUI: "MetaRight",
|
||||
|
||||
// Missing keys:
|
||||
// driver.KeyPrintScreen
|
||||
@ -200,72 +249,76 @@ func init() {
|
||||
// driver.KeyMenu
|
||||
}
|
||||
|
||||
// The driver key and JS key are almost same but very slightly different (e.g., 'A' vs 'KeyA').
|
||||
driverKeyNameToJSKey = map[string]string{
|
||||
"Comma": "Comma",
|
||||
"Period": "Period",
|
||||
"LeftAlt": "AltLeft",
|
||||
"RightAlt": "AltRight",
|
||||
"CapsLock": "CapsLock",
|
||||
"LeftControl": "ControlLeft",
|
||||
"RightControl": "ControlRight",
|
||||
"LeftShift": "ShiftLeft",
|
||||
"RightShift": "ShiftRight",
|
||||
"Enter": "Enter",
|
||||
"Space": "Space",
|
||||
"Tab": "Tab",
|
||||
"Delete": "Delete",
|
||||
"End": "End",
|
||||
"Home": "Home",
|
||||
"Insert": "Insert",
|
||||
"PageDown": "PageDown",
|
||||
"PageUp": "PageUp",
|
||||
"Down": "ArrowDown",
|
||||
"Left": "ArrowLeft",
|
||||
"Right": "ArrowRight",
|
||||
"Up": "ArrowUp",
|
||||
"Escape": "Escape",
|
||||
"Backspace": "Backspace",
|
||||
"Apostrophe": "Quote",
|
||||
"Minus": "Minus",
|
||||
"Slash": "Slash",
|
||||
"Semicolon": "Semicolon",
|
||||
"Equal": "Equal",
|
||||
"LeftBracket": "BracketLeft",
|
||||
"Backslash": "Backslash",
|
||||
"RightBracket": "BracketRight",
|
||||
"GraveAccent": "Backquote",
|
||||
"NumLock": "NumLock",
|
||||
"Pause": "Pause",
|
||||
"PrintScreen": "PrintScreen",
|
||||
"ScrollLock": "ScrollLock",
|
||||
"Menu": "ContextMenu",
|
||||
"KPDecimal": "NumpadDecimal",
|
||||
"KPDivide": "NumpadDivide",
|
||||
"KPMultiply": "NumpadMultiply",
|
||||
"KPSubtract": "NumpadSubtract",
|
||||
"KPAdd": "NumpadAdd",
|
||||
"KPEnter": "NumpadEnter",
|
||||
"KPEqual": "NumpadEqual",
|
||||
"LeftSuper": "MetaLeft",
|
||||
"RightSuper": "MetaRight",
|
||||
"Comma": "Comma",
|
||||
"Period": "Period",
|
||||
"AltLeft": "AltLeft",
|
||||
"AltRight": "AltRight",
|
||||
"CapsLock": "CapsLock",
|
||||
"ControlLeft": "ControlLeft",
|
||||
"ControlRight": "ControlRight",
|
||||
"ShiftLeft": "ShiftLeft",
|
||||
"ShiftRight": "ShiftRight",
|
||||
"Enter": "Enter",
|
||||
"Space": "Space",
|
||||
"Tab": "Tab",
|
||||
"Delete": "Delete",
|
||||
"End": "End",
|
||||
"Home": "Home",
|
||||
"Insert": "Insert",
|
||||
"PageDown": "PageDown",
|
||||
"PageUp": "PageUp",
|
||||
"ArrowDown": "ArrowDown",
|
||||
"ArrowLeft": "ArrowLeft",
|
||||
"ArrowRight": "ArrowRight",
|
||||
"ArrowUp": "ArrowUp",
|
||||
"Escape": "Escape",
|
||||
"Backspace": "Backspace",
|
||||
"Quote": "Quote",
|
||||
"Minus": "Minus",
|
||||
"Slash": "Slash",
|
||||
"Semicolon": "Semicolon",
|
||||
"Equal": "Equal",
|
||||
"BracketLeft": "BracketLeft",
|
||||
"Backslash": "Backslash",
|
||||
"BracketRight": "BracketRight",
|
||||
"Backquote": "Backquote",
|
||||
"NumLock": "NumLock",
|
||||
"Pause": "Pause",
|
||||
"PrintScreen": "PrintScreen",
|
||||
"ScrollLock": "ScrollLock",
|
||||
"ContextMenu": "ContextMenu",
|
||||
"NumpadAdd": "NumpadAdd",
|
||||
"NumpadDecimal": "NumpadDecimal",
|
||||
"NumpadDivide": "NumpadDivide",
|
||||
"NumpadMultiply": "NumpadMultiply",
|
||||
"NumpadSubtract": "NumpadSubtract",
|
||||
"NumpadEnter": "NumpadEnter",
|
||||
"NumpadEqual": "NumpadEqual",
|
||||
"MetaLeft": "MetaLeft",
|
||||
"MetaRight": "MetaRight",
|
||||
}
|
||||
|
||||
// ASCII: 0 - 9
|
||||
for c := '0'; c <= '9'; c++ {
|
||||
glfwKeyNameToGLFWKey[string(c)] = glfw.Key0 + glfw.Key(c) - '0'
|
||||
androidKeyToDriverKeyName[7+int(c)-'0'] = string(c)
|
||||
name := "Digit" + string(c)
|
||||
driverKeyNameToGLFWKeyName[name] = string(c)
|
||||
androidKeyToDriverKeyName[7+int(c)-'0'] = name
|
||||
// Gomobile's key code (= USB HID key codes) has successive key codes for 1, 2, ..., 9, 0
|
||||
// in this order.
|
||||
if c == '0' {
|
||||
gbuildKeyToDriverKeyName[key.Code0] = string(c)
|
||||
gbuildKeyToDriverKeyName[key.Code0] = name
|
||||
} else {
|
||||
gbuildKeyToDriverKeyName[key.Code1+key.Code(c)-'1'] = string(c)
|
||||
gbuildKeyToDriverKeyName[key.Code1+key.Code(c)-'1'] = name
|
||||
}
|
||||
driverKeyNameToJSKey[string(c)] = "Digit" + string(c)
|
||||
driverKeyNameToJSKey[name] = name
|
||||
}
|
||||
// ASCII: A - Z
|
||||
for c := 'A'; c <= 'Z'; c++ {
|
||||
glfwKeyNameToGLFWKey[string(c)] = glfw.KeyA + glfw.Key(c) - 'A'
|
||||
driverKeyNameToGLFWKeyName[string(c)] = string(c)
|
||||
androidKeyToDriverKeyName[29+int(c)-'A'] = string(c)
|
||||
gbuildKeyToDriverKeyName[key.CodeA+key.Code(c)-'A'] = string(c)
|
||||
driverKeyNameToJSKey[string(c)] = "Key" + string(c)
|
||||
@ -274,6 +327,7 @@ func init() {
|
||||
for i := 1; i <= 12; i++ {
|
||||
name := "F" + strconv.Itoa(i)
|
||||
glfwKeyNameToGLFWKey[name] = glfw.KeyF1 + glfw.Key(i) - 1
|
||||
driverKeyNameToGLFWKeyName[name] = name
|
||||
androidKeyToDriverKeyName[131+i-1] = name
|
||||
gbuildKeyToDriverKeyName[key.CodeF1+key.Code(i)-1] = name
|
||||
driverKeyNameToJSKey[name] = name
|
||||
@ -281,8 +335,9 @@ func init() {
|
||||
// Numpad
|
||||
// https://www.w3.org/TR/uievents-code/#key-numpad-section
|
||||
for c := '0'; c <= '9'; c++ {
|
||||
name := "KP" + string(c)
|
||||
glfwKeyNameToGLFWKey[name] = glfw.KeyKP0 + glfw.Key(c) - '0'
|
||||
name := "Numpad" + string(c)
|
||||
glfwKeyNameToGLFWKey["KP"+string(c)] = glfw.KeyKP0 + glfw.Key(c) - '0'
|
||||
driverKeyNameToGLFWKeyName[name] = "KP" + string(c)
|
||||
androidKeyToDriverKeyName[144+int(c)-'0'] = name
|
||||
// Gomobile's key code (= USB HID key codes) has successive key codes for 1, 2, ..., 9, 0
|
||||
// in this order.
|
||||
@ -291,7 +346,46 @@ func init() {
|
||||
} else {
|
||||
gbuildKeyToDriverKeyName[key.CodeKeypad1+key.Code(c)-'1'] = name
|
||||
}
|
||||
driverKeyNameToJSKey[name] = "Numpad" + string(c)
|
||||
driverKeyNameToJSKey[name] = name
|
||||
}
|
||||
|
||||
// Keys for backward compatibility
|
||||
oldEbitenKeyNameToDriverKeyName = map[string]string{
|
||||
"0": "Digit0",
|
||||
"1": "Digit1",
|
||||
"2": "Digit2",
|
||||
"3": "Digit3",
|
||||
"4": "Digit4",
|
||||
"5": "Digit5",
|
||||
"6": "Digit6",
|
||||
"7": "Digit7",
|
||||
"8": "Digit8",
|
||||
"9": "Digit9",
|
||||
"Apostrophe": "Quote",
|
||||
"Down": "ArrowDown",
|
||||
"GraveAccent": "Backquote",
|
||||
"KP0": "Numpad0",
|
||||
"KP1": "Numpad1",
|
||||
"KP2": "Numpad2",
|
||||
"KP3": "Numpad3",
|
||||
"KP4": "Numpad4",
|
||||
"KP5": "Numpad5",
|
||||
"KP6": "Numpad6",
|
||||
"KP7": "Numpad7",
|
||||
"KP8": "Numpad8",
|
||||
"KP9": "Numpad9",
|
||||
"KPDecimal": "NumpadDecimal",
|
||||
"KPDivide": "NumpadDivide",
|
||||
"KPMultiply": "NumpadMultiply",
|
||||
"KPSubtract": "NumpadSubtract",
|
||||
"KPEnter": "NumpadEnter",
|
||||
"KPEqual": "NumpadEqual",
|
||||
"Left": "ArrowLeft",
|
||||
"LeftBracket": "BracketLeft",
|
||||
"Menu": "ContextMenu",
|
||||
"Right": "ArrowRight",
|
||||
"RightBracket": "BracketRight",
|
||||
"Up": "ArrowUp",
|
||||
}
|
||||
}
|
||||
|
||||
@ -301,10 +395,10 @@ func init() {
|
||||
edgeKeyCodeToName = map[int]string{
|
||||
0xbc: "Comma",
|
||||
0xbe: "Period",
|
||||
0x12: "LeftAlt",
|
||||
0x12: "AltLeft",
|
||||
0x14: "CapsLock",
|
||||
0x11: "LeftControl",
|
||||
0x10: "LeftShift",
|
||||
0x11: "ControlLeft",
|
||||
0x10: "ShiftLeft",
|
||||
0x0D: "Enter",
|
||||
0x20: "Space",
|
||||
0x09: "Tab",
|
||||
@ -314,43 +408,43 @@ func init() {
|
||||
0x2D: "Insert",
|
||||
0x22: "PageDown",
|
||||
0x21: "PageUp",
|
||||
0x28: "Down",
|
||||
0x25: "Left",
|
||||
0x27: "Right",
|
||||
0x26: "Up",
|
||||
0x28: "ArrowDown",
|
||||
0x25: "ArrowLeft",
|
||||
0x27: "ArrowRight",
|
||||
0x26: "ArrowUp",
|
||||
0x1B: "Escape",
|
||||
0xde: "Apostrophe",
|
||||
0xde: "Quote",
|
||||
0xbd: "Minus",
|
||||
0xbf: "Slash",
|
||||
0xba: "Semicolon",
|
||||
0xbb: "Equal",
|
||||
0xdb: "LeftBracket",
|
||||
0xdb: "BracketLeft",
|
||||
0xdc: "Backslash",
|
||||
0xdd: "RightBracket",
|
||||
0xc0: "GraveAccent",
|
||||
0xdd: "BracketRight",
|
||||
0xc0: "Backquote",
|
||||
0x08: "Backspace",
|
||||
0x90: "NumLock",
|
||||
0x6e: "KPDecimal",
|
||||
0x6f: "KPDivide",
|
||||
0x6a: "KPMultiply",
|
||||
0x6d: "KPSubtract",
|
||||
0x6b: "KPAdd",
|
||||
0x6b: "NumpadAdd",
|
||||
0x6e: "NumpadDecimal",
|
||||
0x6f: "NumpadDivide",
|
||||
0x6a: "NumpadMultiply",
|
||||
0x6d: "NumpadSubtract",
|
||||
0x13: "Pause",
|
||||
0x91: "ScrollLock",
|
||||
0x5d: "Menu",
|
||||
0x5b: "LeftSuper",
|
||||
0x5c: "RightSuper",
|
||||
0x5d: "ContextMenu",
|
||||
0x5b: "MetaLeft",
|
||||
0x5c: "MetaRight",
|
||||
|
||||
// On Edge, this key does not work. PrintScreen works only on keyup event.
|
||||
// 0x2C: "PrintScreen",
|
||||
|
||||
// On Edge, it is impossible to tell KPEnter and Enter / KPEqual and Equal.
|
||||
// 0x0d: "KPEnter",
|
||||
// 0x0c: "KPEqual",
|
||||
// On Edge, it is impossible to tell NumpadEnter and Enter / NumpadEqual and Equal.
|
||||
// 0x0d: "NumpadEnter",
|
||||
// 0x0c: "NumpadEqual",
|
||||
}
|
||||
// ASCII: 0 - 9
|
||||
for c := '0'; c <= '9'; c++ {
|
||||
edgeKeyCodeToName[int(c)] = string(c)
|
||||
edgeKeyCodeToName[int(c)] = "Digit" + string(c)
|
||||
}
|
||||
// ASCII: A - Z
|
||||
for c := 'A'; c <= 'Z'; c++ {
|
||||
@ -362,7 +456,7 @@ func init() {
|
||||
}
|
||||
// Numpad keys
|
||||
for c := '0'; c <= '9'; c++ {
|
||||
edgeKeyCodeToName[0x60+int(c-'0')] = "KP" + string(c)
|
||||
edgeKeyCodeToName[0x60+int(c-'0')] = "Numpad" + string(c)
|
||||
}
|
||||
}
|
||||
|
||||
@ -386,16 +480,21 @@ type Key int
|
||||
// Keys.
|
||||
const (
|
||||
{{range $index, $name := .EbitenKeyNamesWithoutMods}}Key{{$name}} Key = Key(driver.Key{{$name}})
|
||||
{{end}} KeyAlt Key = Key(driver.KeyReserved0)
|
||||
{{end}} KeyAlt Key = Key(driver.KeyReserved0)
|
||||
KeyControl Key = Key(driver.KeyReserved1)
|
||||
KeyShift Key = Key(driver.KeyReserved2)
|
||||
KeySuper Key = Key(driver.KeyReserved3)
|
||||
KeyMax Key = KeySuper
|
||||
KeyShift Key = Key(driver.KeyReserved2)
|
||||
KeyMeta Key = Key(driver.KeyReserved3)
|
||||
KeyMax Key = KeyMeta
|
||||
|
||||
// Keys for backward compatibility.
|
||||
// Deprecated: as of 2.1.0.
|
||||
{{range $old, $new := .OldEbitenKeyNameToDriverKeyName}}Key{{$old}} Key = Key(driver.Key{{$new}})
|
||||
{{end}}
|
||||
)
|
||||
|
||||
func (k Key) isValid() bool {
|
||||
switch k {
|
||||
{{range $name := .EbitenKeyNames}}case Key{{$name}}:
|
||||
{{range $name := .EbitenKeyNamesWithoutOld}}case Key{{$name}}:
|
||||
return true
|
||||
{{end}}
|
||||
default:
|
||||
@ -408,7 +507,7 @@ func (k Key) isValid() bool {
|
||||
// If k is an undefined key, String returns an empty string.
|
||||
func (k Key) String() string {
|
||||
switch k {
|
||||
{{range $name := .EbitenKeyNames}}case Key{{$name}}:
|
||||
{{range $name := .EbitenKeyNamesWithoutOld}}case Key{{$name}}:
|
||||
return {{$name | printf "%q"}}
|
||||
{{end}}}
|
||||
return ""
|
||||
@ -484,12 +583,12 @@ import (
|
||||
)
|
||||
|
||||
var glfwKeyToDriverKey = map[glfw.Key]driver.Key{
|
||||
{{range $index, $name := .DriverKeyNames}}glfw.Key{{$name}}: driver.Key{{$name}},
|
||||
{{range $dname, $gname := .DriverKeyNameToGLFWKeyName}}glfw.Key{{$gname}}: driver.Key{{$dname}},
|
||||
{{end}}
|
||||
}
|
||||
|
||||
var driverKeyToGLFWKey = map[driver.Key]glfw.Key{
|
||||
{{range $index, $name := .DriverKeyNames}}driver.Key{{$name}}: glfw.Key{{$name}},
|
||||
{{range $dname, $gname := .DriverKeyNameToGLFWKeyName}}driver.Key{{$dname}}: glfw.Key{{$gname}},
|
||||
{{end}}
|
||||
}
|
||||
`
|
||||
@ -661,17 +760,25 @@ func main() {
|
||||
doNotEdit := "// Code generated by genkeys.go using 'go generate'. DO NOT EDIT."
|
||||
|
||||
ebitenKeyNames := []string{}
|
||||
ebitenKeyNamesWithoutOld := []string{}
|
||||
ebitenKeyNamesWithoutMods := []string{}
|
||||
driverKeyNames := []string{}
|
||||
|
||||
for name := range driverKeyNameToJSKey {
|
||||
driverKeyNames = append(driverKeyNames, name)
|
||||
ebitenKeyNames = append(ebitenKeyNames, name)
|
||||
ebitenKeyNamesWithoutOld = append(ebitenKeyNamesWithoutOld, name)
|
||||
ebitenKeyNamesWithoutMods = append(ebitenKeyNamesWithoutMods, name)
|
||||
}
|
||||
ebitenKeyNames = append(ebitenKeyNames, "Alt", "Control", "Shift", "Super")
|
||||
for old := range oldEbitenKeyNameToDriverKeyName {
|
||||
ebitenKeyNames = append(ebitenKeyNames, old)
|
||||
}
|
||||
// Keys for modifiers
|
||||
ebitenKeyNames = append(ebitenKeyNames, "Alt", "Control", "Shift", "Meta")
|
||||
ebitenKeyNamesWithoutOld = append(ebitenKeyNamesWithoutOld, "Alt", "Control", "Shift", "Meta")
|
||||
|
||||
sort.Slice(ebitenKeyNames, keyNamesLess(ebitenKeyNames))
|
||||
sort.Slice(ebitenKeyNamesWithoutOld, keyNamesLess(ebitenKeyNamesWithoutOld))
|
||||
sort.Slice(ebitenKeyNamesWithoutMods, keyNamesLess(ebitenKeyNamesWithoutMods))
|
||||
sort.Slice(driverKeyNames, keyNamesLess(driverKeyNames))
|
||||
|
||||
@ -715,29 +822,35 @@ func main() {
|
||||
}
|
||||
// NOTE: According to godoc, maps are automatically sorted by key.
|
||||
if err := tmpl.Execute(f, struct {
|
||||
License string
|
||||
DoNotEdit string
|
||||
BuildTag string
|
||||
DriverKeyNameToJSKey map[string]string
|
||||
EdgeKeyCodeToName map[int]string
|
||||
EbitenKeyNames []string
|
||||
EbitenKeyNamesWithoutMods []string
|
||||
DriverKeyNames []string
|
||||
GLFWKeyNameToGLFWKey map[string]glfw.Key
|
||||
AndroidKeyToDriverKeyName map[int]string
|
||||
GBuildKeyToDriverKeyName map[key.Code]string
|
||||
License string
|
||||
DoNotEdit string
|
||||
BuildTag string
|
||||
DriverKeyNameToJSKey map[string]string
|
||||
EdgeKeyCodeToName map[int]string
|
||||
EbitenKeyNames []string
|
||||
EbitenKeyNamesWithoutOld []string
|
||||
EbitenKeyNamesWithoutMods []string
|
||||
GLFWKeyNameToGLFWKey map[string]glfw.Key
|
||||
DriverKeyNames []string
|
||||
DriverKeyNameToGLFWKeyName map[string]string
|
||||
AndroidKeyToDriverKeyName map[int]string
|
||||
GBuildKeyToDriverKeyName map[key.Code]string
|
||||
OldEbitenKeyNameToDriverKeyName map[string]string
|
||||
}{
|
||||
License: license,
|
||||
DoNotEdit: doNotEdit,
|
||||
BuildTag: buildTag,
|
||||
DriverKeyNameToJSKey: driverKeyNameToJSKey,
|
||||
EdgeKeyCodeToName: edgeKeyCodeToName,
|
||||
EbitenKeyNames: ebitenKeyNames,
|
||||
EbitenKeyNamesWithoutMods: ebitenKeyNamesWithoutMods,
|
||||
DriverKeyNames: driverKeyNames,
|
||||
GLFWKeyNameToGLFWKey: glfwKeyNameToGLFWKey,
|
||||
AndroidKeyToDriverKeyName: androidKeyToDriverKeyName,
|
||||
GBuildKeyToDriverKeyName: gbuildKeyToDriverKeyName,
|
||||
License: license,
|
||||
DoNotEdit: doNotEdit,
|
||||
BuildTag: buildTag,
|
||||
DriverKeyNameToJSKey: driverKeyNameToJSKey,
|
||||
EdgeKeyCodeToName: edgeKeyCodeToName,
|
||||
EbitenKeyNames: ebitenKeyNames,
|
||||
EbitenKeyNamesWithoutOld: ebitenKeyNamesWithoutOld,
|
||||
EbitenKeyNamesWithoutMods: ebitenKeyNamesWithoutMods,
|
||||
GLFWKeyNameToGLFWKey: glfwKeyNameToGLFWKey,
|
||||
DriverKeyNames: driverKeyNames,
|
||||
DriverKeyNameToGLFWKeyName: driverKeyNameToGLFWKeyName,
|
||||
AndroidKeyToDriverKeyName: androidKeyToDriverKeyName,
|
||||
GBuildKeyToDriverKeyName: gbuildKeyToDriverKeyName,
|
||||
OldEbitenKeyNameToDriverKeyName: oldEbitenKeyNameToDriverKeyName,
|
||||
}); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
10
input.go
10
input.go
@ -58,13 +58,13 @@ func IsKeyPressed(key Key) bool {
|
||||
var keys []driver.Key
|
||||
switch key {
|
||||
case KeyAlt:
|
||||
keys = []driver.Key{driver.KeyLeftAlt, driver.KeyRightAlt}
|
||||
keys = []driver.Key{driver.KeyAltLeft, driver.KeyAltRight}
|
||||
case KeyControl:
|
||||
keys = []driver.Key{driver.KeyLeftControl, driver.KeyRightControl}
|
||||
keys = []driver.Key{driver.KeyControlLeft, driver.KeyControlRight}
|
||||
case KeyShift:
|
||||
keys = []driver.Key{driver.KeyLeftShift, driver.KeyRightShift}
|
||||
case KeySuper:
|
||||
keys = []driver.Key{driver.KeyLeftSuper, driver.KeyRightSuper}
|
||||
keys = []driver.Key{driver.KeyShiftLeft, driver.KeyShiftRight}
|
||||
case KeyMeta:
|
||||
keys = []driver.Key{driver.KeyMetaLeft, driver.KeyMetaRight}
|
||||
default:
|
||||
keys = []driver.Key{driver.Key(key)}
|
||||
}
|
||||
|
@ -23,17 +23,7 @@ import (
|
||||
type Key int
|
||||
|
||||
const (
|
||||
Key0 Key = iota
|
||||
Key1
|
||||
Key2
|
||||
Key3
|
||||
Key4
|
||||
Key5
|
||||
Key6
|
||||
Key7
|
||||
Key8
|
||||
Key9
|
||||
KeyA
|
||||
KeyA Key = iota
|
||||
KeyB
|
||||
KeyC
|
||||
KeyD
|
||||
@ -59,13 +49,33 @@ const (
|
||||
KeyX
|
||||
KeyY
|
||||
KeyZ
|
||||
KeyApostrophe
|
||||
KeyAltLeft
|
||||
KeyAltRight
|
||||
KeyArrowDown
|
||||
KeyArrowLeft
|
||||
KeyArrowRight
|
||||
KeyArrowUp
|
||||
KeyBackquote
|
||||
KeyBackslash
|
||||
KeyBackspace
|
||||
KeyBracketLeft
|
||||
KeyBracketRight
|
||||
KeyCapsLock
|
||||
KeyComma
|
||||
KeyContextMenu
|
||||
KeyControlLeft
|
||||
KeyControlRight
|
||||
KeyDelete
|
||||
KeyDown
|
||||
KeyDigit0
|
||||
KeyDigit1
|
||||
KeyDigit2
|
||||
KeyDigit3
|
||||
KeyDigit4
|
||||
KeyDigit5
|
||||
KeyDigit6
|
||||
KeyDigit7
|
||||
KeyDigit8
|
||||
KeyDigit9
|
||||
KeyEnd
|
||||
KeyEnter
|
||||
KeyEqual
|
||||
@ -82,52 +92,42 @@ const (
|
||||
KeyF10
|
||||
KeyF11
|
||||
KeyF12
|
||||
KeyGraveAccent
|
||||
KeyHome
|
||||
KeyInsert
|
||||
KeyKP0
|
||||
KeyKP1
|
||||
KeyKP2
|
||||
KeyKP3
|
||||
KeyKP4
|
||||
KeyKP5
|
||||
KeyKP6
|
||||
KeyKP7
|
||||
KeyKP8
|
||||
KeyKP9
|
||||
KeyKPAdd
|
||||
KeyKPDecimal
|
||||
KeyKPDivide
|
||||
KeyKPEnter
|
||||
KeyKPEqual
|
||||
KeyKPMultiply
|
||||
KeyKPSubtract
|
||||
KeyLeft
|
||||
KeyLeftAlt
|
||||
KeyLeftBracket
|
||||
KeyLeftControl
|
||||
KeyLeftShift
|
||||
KeyLeftSuper
|
||||
KeyMenu
|
||||
KeyMetaLeft
|
||||
KeyMetaRight
|
||||
KeyMinus
|
||||
KeyNumLock
|
||||
KeyNumpad0
|
||||
KeyNumpad1
|
||||
KeyNumpad2
|
||||
KeyNumpad3
|
||||
KeyNumpad4
|
||||
KeyNumpad5
|
||||
KeyNumpad6
|
||||
KeyNumpad7
|
||||
KeyNumpad8
|
||||
KeyNumpad9
|
||||
KeyNumpadAdd
|
||||
KeyNumpadDecimal
|
||||
KeyNumpadDivide
|
||||
KeyNumpadEnter
|
||||
KeyNumpadEqual
|
||||
KeyNumpadMultiply
|
||||
KeyNumpadSubtract
|
||||
KeyPageDown
|
||||
KeyPageUp
|
||||
KeyPause
|
||||
KeyPeriod
|
||||
KeyPrintScreen
|
||||
KeyRight
|
||||
KeyRightAlt
|
||||
KeyRightBracket
|
||||
KeyRightControl
|
||||
KeyRightShift
|
||||
KeyRightSuper
|
||||
KeyQuote
|
||||
KeyScrollLock
|
||||
KeySemicolon
|
||||
KeyShiftLeft
|
||||
KeyShiftRight
|
||||
KeySlash
|
||||
KeySpace
|
||||
KeyTab
|
||||
KeyUp
|
||||
KeyReserved0
|
||||
KeyReserved1
|
||||
KeyReserved2
|
||||
@ -136,26 +136,6 @@ const (
|
||||
|
||||
func (k Key) String() string {
|
||||
switch k {
|
||||
case Key0:
|
||||
return "Key0"
|
||||
case Key1:
|
||||
return "Key1"
|
||||
case Key2:
|
||||
return "Key2"
|
||||
case Key3:
|
||||
return "Key3"
|
||||
case Key4:
|
||||
return "Key4"
|
||||
case Key5:
|
||||
return "Key5"
|
||||
case Key6:
|
||||
return "Key6"
|
||||
case Key7:
|
||||
return "Key7"
|
||||
case Key8:
|
||||
return "Key8"
|
||||
case Key9:
|
||||
return "Key9"
|
||||
case KeyA:
|
||||
return "KeyA"
|
||||
case KeyB:
|
||||
@ -208,20 +188,60 @@ func (k Key) String() string {
|
||||
return "KeyY"
|
||||
case KeyZ:
|
||||
return "KeyZ"
|
||||
case KeyApostrophe:
|
||||
return "KeyApostrophe"
|
||||
case KeyAltLeft:
|
||||
return "KeyAltLeft"
|
||||
case KeyAltRight:
|
||||
return "KeyAltRight"
|
||||
case KeyArrowDown:
|
||||
return "KeyArrowDown"
|
||||
case KeyArrowLeft:
|
||||
return "KeyArrowLeft"
|
||||
case KeyArrowRight:
|
||||
return "KeyArrowRight"
|
||||
case KeyArrowUp:
|
||||
return "KeyArrowUp"
|
||||
case KeyBackquote:
|
||||
return "KeyBackquote"
|
||||
case KeyBackslash:
|
||||
return "KeyBackslash"
|
||||
case KeyBackspace:
|
||||
return "KeyBackspace"
|
||||
case KeyBracketLeft:
|
||||
return "KeyBracketLeft"
|
||||
case KeyBracketRight:
|
||||
return "KeyBracketRight"
|
||||
case KeyCapsLock:
|
||||
return "KeyCapsLock"
|
||||
case KeyComma:
|
||||
return "KeyComma"
|
||||
case KeyContextMenu:
|
||||
return "KeyContextMenu"
|
||||
case KeyControlLeft:
|
||||
return "KeyControlLeft"
|
||||
case KeyControlRight:
|
||||
return "KeyControlRight"
|
||||
case KeyDelete:
|
||||
return "KeyDelete"
|
||||
case KeyDown:
|
||||
return "KeyDown"
|
||||
case KeyDigit0:
|
||||
return "KeyDigit0"
|
||||
case KeyDigit1:
|
||||
return "KeyDigit1"
|
||||
case KeyDigit2:
|
||||
return "KeyDigit2"
|
||||
case KeyDigit3:
|
||||
return "KeyDigit3"
|
||||
case KeyDigit4:
|
||||
return "KeyDigit4"
|
||||
case KeyDigit5:
|
||||
return "KeyDigit5"
|
||||
case KeyDigit6:
|
||||
return "KeyDigit6"
|
||||
case KeyDigit7:
|
||||
return "KeyDigit7"
|
||||
case KeyDigit8:
|
||||
return "KeyDigit8"
|
||||
case KeyDigit9:
|
||||
return "KeyDigit9"
|
||||
case KeyEnd:
|
||||
return "KeyEnd"
|
||||
case KeyEnter:
|
||||
@ -254,64 +274,52 @@ func (k Key) String() string {
|
||||
return "KeyF11"
|
||||
case KeyF12:
|
||||
return "KeyF12"
|
||||
case KeyGraveAccent:
|
||||
return "KeyGraveAccent"
|
||||
case KeyHome:
|
||||
return "KeyHome"
|
||||
case KeyInsert:
|
||||
return "KeyInsert"
|
||||
case KeyKP0:
|
||||
return "KeyKP0"
|
||||
case KeyKP1:
|
||||
return "KeyKP1"
|
||||
case KeyKP2:
|
||||
return "KeyKP2"
|
||||
case KeyKP3:
|
||||
return "KeyKP3"
|
||||
case KeyKP4:
|
||||
return "KeyKP4"
|
||||
case KeyKP5:
|
||||
return "KeyKP5"
|
||||
case KeyKP6:
|
||||
return "KeyKP6"
|
||||
case KeyKP7:
|
||||
return "KeyKP7"
|
||||
case KeyKP8:
|
||||
return "KeyKP8"
|
||||
case KeyKP9:
|
||||
return "KeyKP9"
|
||||
case KeyKPAdd:
|
||||
return "KeyKPAdd"
|
||||
case KeyKPDecimal:
|
||||
return "KeyKPDecimal"
|
||||
case KeyKPDivide:
|
||||
return "KeyKPDivide"
|
||||
case KeyKPEnter:
|
||||
return "KeyKPEnter"
|
||||
case KeyKPEqual:
|
||||
return "KeyKPEqual"
|
||||
case KeyKPMultiply:
|
||||
return "KeyKPMultiply"
|
||||
case KeyKPSubtract:
|
||||
return "KeyKPSubtract"
|
||||
case KeyLeft:
|
||||
return "KeyLeft"
|
||||
case KeyLeftAlt:
|
||||
return "KeyLeftAlt"
|
||||
case KeyLeftBracket:
|
||||
return "KeyLeftBracket"
|
||||
case KeyLeftControl:
|
||||
return "KeyLeftControl"
|
||||
case KeyLeftShift:
|
||||
return "KeyLeftShift"
|
||||
case KeyLeftSuper:
|
||||
return "KeyLeftSuper"
|
||||
case KeyMenu:
|
||||
return "KeyMenu"
|
||||
case KeyMetaLeft:
|
||||
return "KeyMetaLeft"
|
||||
case KeyMetaRight:
|
||||
return "KeyMetaRight"
|
||||
case KeyMinus:
|
||||
return "KeyMinus"
|
||||
case KeyNumLock:
|
||||
return "KeyNumLock"
|
||||
case KeyNumpad0:
|
||||
return "KeyNumpad0"
|
||||
case KeyNumpad1:
|
||||
return "KeyNumpad1"
|
||||
case KeyNumpad2:
|
||||
return "KeyNumpad2"
|
||||
case KeyNumpad3:
|
||||
return "KeyNumpad3"
|
||||
case KeyNumpad4:
|
||||
return "KeyNumpad4"
|
||||
case KeyNumpad5:
|
||||
return "KeyNumpad5"
|
||||
case KeyNumpad6:
|
||||
return "KeyNumpad6"
|
||||
case KeyNumpad7:
|
||||
return "KeyNumpad7"
|
||||
case KeyNumpad8:
|
||||
return "KeyNumpad8"
|
||||
case KeyNumpad9:
|
||||
return "KeyNumpad9"
|
||||
case KeyNumpadAdd:
|
||||
return "KeyNumpadAdd"
|
||||
case KeyNumpadDecimal:
|
||||
return "KeyNumpadDecimal"
|
||||
case KeyNumpadDivide:
|
||||
return "KeyNumpadDivide"
|
||||
case KeyNumpadEnter:
|
||||
return "KeyNumpadEnter"
|
||||
case KeyNumpadEqual:
|
||||
return "KeyNumpadEqual"
|
||||
case KeyNumpadMultiply:
|
||||
return "KeyNumpadMultiply"
|
||||
case KeyNumpadSubtract:
|
||||
return "KeyNumpadSubtract"
|
||||
case KeyPageDown:
|
||||
return "KeyPageDown"
|
||||
case KeyPageUp:
|
||||
@ -322,30 +330,22 @@ func (k Key) String() string {
|
||||
return "KeyPeriod"
|
||||
case KeyPrintScreen:
|
||||
return "KeyPrintScreen"
|
||||
case KeyRight:
|
||||
return "KeyRight"
|
||||
case KeyRightAlt:
|
||||
return "KeyRightAlt"
|
||||
case KeyRightBracket:
|
||||
return "KeyRightBracket"
|
||||
case KeyRightControl:
|
||||
return "KeyRightControl"
|
||||
case KeyRightShift:
|
||||
return "KeyRightShift"
|
||||
case KeyRightSuper:
|
||||
return "KeyRightSuper"
|
||||
case KeyQuote:
|
||||
return "KeyQuote"
|
||||
case KeyScrollLock:
|
||||
return "KeyScrollLock"
|
||||
case KeySemicolon:
|
||||
return "KeySemicolon"
|
||||
case KeyShiftLeft:
|
||||
return "KeyShiftLeft"
|
||||
case KeyShiftRight:
|
||||
return "KeyShiftRight"
|
||||
case KeySlash:
|
||||
return "KeySlash"
|
||||
case KeySpace:
|
||||
return "KeySpace"
|
||||
case KeyTab:
|
||||
return "KeyTab"
|
||||
case KeyUp:
|
||||
return "KeyUp"
|
||||
}
|
||||
panic(fmt.Sprintf("driver: invalid key: %d", k))
|
||||
}
|
||||
|
@ -26,54 +26,47 @@ import (
|
||||
)
|
||||
|
||||
var glfwKeyToDriverKey = map[glfw.Key]driver.Key{
|
||||
glfw.Key0: driver.Key0,
|
||||
glfw.Key1: driver.Key1,
|
||||
glfw.Key2: driver.Key2,
|
||||
glfw.Key3: driver.Key3,
|
||||
glfw.Key4: driver.Key4,
|
||||
glfw.Key5: driver.Key5,
|
||||
glfw.Key6: driver.Key6,
|
||||
glfw.Key7: driver.Key7,
|
||||
glfw.Key8: driver.Key8,
|
||||
glfw.Key9: driver.Key9,
|
||||
glfw.KeyA: driver.KeyA,
|
||||
glfw.KeyLeftAlt: driver.KeyAltLeft,
|
||||
glfw.KeyRightAlt: driver.KeyAltRight,
|
||||
glfw.KeyDown: driver.KeyArrowDown,
|
||||
glfw.KeyLeft: driver.KeyArrowLeft,
|
||||
glfw.KeyRight: driver.KeyArrowRight,
|
||||
glfw.KeyUp: driver.KeyArrowUp,
|
||||
glfw.KeyB: driver.KeyB,
|
||||
glfw.KeyC: driver.KeyC,
|
||||
glfw.KeyD: driver.KeyD,
|
||||
glfw.KeyE: driver.KeyE,
|
||||
glfw.KeyF: driver.KeyF,
|
||||
glfw.KeyG: driver.KeyG,
|
||||
glfw.KeyH: driver.KeyH,
|
||||
glfw.KeyI: driver.KeyI,
|
||||
glfw.KeyJ: driver.KeyJ,
|
||||
glfw.KeyK: driver.KeyK,
|
||||
glfw.KeyL: driver.KeyL,
|
||||
glfw.KeyM: driver.KeyM,
|
||||
glfw.KeyN: driver.KeyN,
|
||||
glfw.KeyO: driver.KeyO,
|
||||
glfw.KeyP: driver.KeyP,
|
||||
glfw.KeyQ: driver.KeyQ,
|
||||
glfw.KeyR: driver.KeyR,
|
||||
glfw.KeyS: driver.KeyS,
|
||||
glfw.KeyT: driver.KeyT,
|
||||
glfw.KeyU: driver.KeyU,
|
||||
glfw.KeyV: driver.KeyV,
|
||||
glfw.KeyW: driver.KeyW,
|
||||
glfw.KeyX: driver.KeyX,
|
||||
glfw.KeyY: driver.KeyY,
|
||||
glfw.KeyZ: driver.KeyZ,
|
||||
glfw.KeyApostrophe: driver.KeyApostrophe,
|
||||
glfw.KeyGraveAccent: driver.KeyBackquote,
|
||||
glfw.KeyBackslash: driver.KeyBackslash,
|
||||
glfw.KeyBackspace: driver.KeyBackspace,
|
||||
glfw.KeyLeftBracket: driver.KeyBracketLeft,
|
||||
glfw.KeyRightBracket: driver.KeyBracketRight,
|
||||
glfw.KeyC: driver.KeyC,
|
||||
glfw.KeyCapsLock: driver.KeyCapsLock,
|
||||
glfw.KeyComma: driver.KeyComma,
|
||||
glfw.KeyMenu: driver.KeyContextMenu,
|
||||
glfw.KeyLeftControl: driver.KeyControlLeft,
|
||||
glfw.KeyRightControl: driver.KeyControlRight,
|
||||
glfw.KeyD: driver.KeyD,
|
||||
glfw.KeyDelete: driver.KeyDelete,
|
||||
glfw.KeyDown: driver.KeyDown,
|
||||
glfw.Key0: driver.KeyDigit0,
|
||||
glfw.Key1: driver.KeyDigit1,
|
||||
glfw.Key2: driver.KeyDigit2,
|
||||
glfw.Key3: driver.KeyDigit3,
|
||||
glfw.Key4: driver.KeyDigit4,
|
||||
glfw.Key5: driver.KeyDigit5,
|
||||
glfw.Key6: driver.KeyDigit6,
|
||||
glfw.Key7: driver.KeyDigit7,
|
||||
glfw.Key8: driver.KeyDigit8,
|
||||
glfw.Key9: driver.KeyDigit9,
|
||||
glfw.KeyE: driver.KeyE,
|
||||
glfw.KeyEnd: driver.KeyEnd,
|
||||
glfw.KeyEnter: driver.KeyEnter,
|
||||
glfw.KeyEqual: driver.KeyEqual,
|
||||
glfw.KeyEscape: driver.KeyEscape,
|
||||
glfw.KeyF: driver.KeyF,
|
||||
glfw.KeyF1: driver.KeyF1,
|
||||
glfw.KeyF10: driver.KeyF10,
|
||||
glfw.KeyF11: driver.KeyF11,
|
||||
glfw.KeyF12: driver.KeyF12,
|
||||
glfw.KeyF2: driver.KeyF2,
|
||||
glfw.KeyF3: driver.KeyF3,
|
||||
glfw.KeyF4: driver.KeyF4,
|
||||
@ -82,161 +75,168 @@ var glfwKeyToDriverKey = map[glfw.Key]driver.Key{
|
||||
glfw.KeyF7: driver.KeyF7,
|
||||
glfw.KeyF8: driver.KeyF8,
|
||||
glfw.KeyF9: driver.KeyF9,
|
||||
glfw.KeyF10: driver.KeyF10,
|
||||
glfw.KeyF11: driver.KeyF11,
|
||||
glfw.KeyF12: driver.KeyF12,
|
||||
glfw.KeyGraveAccent: driver.KeyGraveAccent,
|
||||
glfw.KeyG: driver.KeyG,
|
||||
glfw.KeyH: driver.KeyH,
|
||||
glfw.KeyHome: driver.KeyHome,
|
||||
glfw.KeyI: driver.KeyI,
|
||||
glfw.KeyInsert: driver.KeyInsert,
|
||||
glfw.KeyKP0: driver.KeyKP0,
|
||||
glfw.KeyKP1: driver.KeyKP1,
|
||||
glfw.KeyKP2: driver.KeyKP2,
|
||||
glfw.KeyKP3: driver.KeyKP3,
|
||||
glfw.KeyKP4: driver.KeyKP4,
|
||||
glfw.KeyKP5: driver.KeyKP5,
|
||||
glfw.KeyKP6: driver.KeyKP6,
|
||||
glfw.KeyKP7: driver.KeyKP7,
|
||||
glfw.KeyKP8: driver.KeyKP8,
|
||||
glfw.KeyKP9: driver.KeyKP9,
|
||||
glfw.KeyKPAdd: driver.KeyKPAdd,
|
||||
glfw.KeyKPDecimal: driver.KeyKPDecimal,
|
||||
glfw.KeyKPDivide: driver.KeyKPDivide,
|
||||
glfw.KeyKPEnter: driver.KeyKPEnter,
|
||||
glfw.KeyKPEqual: driver.KeyKPEqual,
|
||||
glfw.KeyKPMultiply: driver.KeyKPMultiply,
|
||||
glfw.KeyKPSubtract: driver.KeyKPSubtract,
|
||||
glfw.KeyLeft: driver.KeyLeft,
|
||||
glfw.KeyLeftAlt: driver.KeyLeftAlt,
|
||||
glfw.KeyLeftBracket: driver.KeyLeftBracket,
|
||||
glfw.KeyLeftControl: driver.KeyLeftControl,
|
||||
glfw.KeyLeftShift: driver.KeyLeftShift,
|
||||
glfw.KeyLeftSuper: driver.KeyLeftSuper,
|
||||
glfw.KeyMenu: driver.KeyMenu,
|
||||
glfw.KeyJ: driver.KeyJ,
|
||||
glfw.KeyK: driver.KeyK,
|
||||
glfw.KeyL: driver.KeyL,
|
||||
glfw.KeyM: driver.KeyM,
|
||||
glfw.KeyLeftSuper: driver.KeyMetaLeft,
|
||||
glfw.KeyRightSuper: driver.KeyMetaRight,
|
||||
glfw.KeyMinus: driver.KeyMinus,
|
||||
glfw.KeyN: driver.KeyN,
|
||||
glfw.KeyNumLock: driver.KeyNumLock,
|
||||
glfw.KeyKP0: driver.KeyNumpad0,
|
||||
glfw.KeyKP1: driver.KeyNumpad1,
|
||||
glfw.KeyKP2: driver.KeyNumpad2,
|
||||
glfw.KeyKP3: driver.KeyNumpad3,
|
||||
glfw.KeyKP4: driver.KeyNumpad4,
|
||||
glfw.KeyKP5: driver.KeyNumpad5,
|
||||
glfw.KeyKP6: driver.KeyNumpad6,
|
||||
glfw.KeyKP7: driver.KeyNumpad7,
|
||||
glfw.KeyKP8: driver.KeyNumpad8,
|
||||
glfw.KeyKP9: driver.KeyNumpad9,
|
||||
glfw.KeyKPAdd: driver.KeyNumpadAdd,
|
||||
glfw.KeyKPDecimal: driver.KeyNumpadDecimal,
|
||||
glfw.KeyKPDivide: driver.KeyNumpadDivide,
|
||||
glfw.KeyKPEnter: driver.KeyNumpadEnter,
|
||||
glfw.KeyKPEqual: driver.KeyNumpadEqual,
|
||||
glfw.KeyKPMultiply: driver.KeyNumpadMultiply,
|
||||
glfw.KeyKPSubtract: driver.KeyNumpadSubtract,
|
||||
glfw.KeyO: driver.KeyO,
|
||||
glfw.KeyP: driver.KeyP,
|
||||
glfw.KeyPageDown: driver.KeyPageDown,
|
||||
glfw.KeyPageUp: driver.KeyPageUp,
|
||||
glfw.KeyPause: driver.KeyPause,
|
||||
glfw.KeyPeriod: driver.KeyPeriod,
|
||||
glfw.KeyPrintScreen: driver.KeyPrintScreen,
|
||||
glfw.KeyRight: driver.KeyRight,
|
||||
glfw.KeyRightAlt: driver.KeyRightAlt,
|
||||
glfw.KeyRightBracket: driver.KeyRightBracket,
|
||||
glfw.KeyRightControl: driver.KeyRightControl,
|
||||
glfw.KeyRightShift: driver.KeyRightShift,
|
||||
glfw.KeyRightSuper: driver.KeyRightSuper,
|
||||
glfw.KeyQ: driver.KeyQ,
|
||||
glfw.KeyApostrophe: driver.KeyQuote,
|
||||
glfw.KeyR: driver.KeyR,
|
||||
glfw.KeyS: driver.KeyS,
|
||||
glfw.KeyScrollLock: driver.KeyScrollLock,
|
||||
glfw.KeySemicolon: driver.KeySemicolon,
|
||||
glfw.KeyLeftShift: driver.KeyShiftLeft,
|
||||
glfw.KeyRightShift: driver.KeyShiftRight,
|
||||
glfw.KeySlash: driver.KeySlash,
|
||||
glfw.KeySpace: driver.KeySpace,
|
||||
glfw.KeyT: driver.KeyT,
|
||||
glfw.KeyTab: driver.KeyTab,
|
||||
glfw.KeyUp: driver.KeyUp,
|
||||
glfw.KeyU: driver.KeyU,
|
||||
glfw.KeyV: driver.KeyV,
|
||||
glfw.KeyW: driver.KeyW,
|
||||
glfw.KeyX: driver.KeyX,
|
||||
glfw.KeyY: driver.KeyY,
|
||||
glfw.KeyZ: driver.KeyZ,
|
||||
}
|
||||
|
||||
var driverKeyToGLFWKey = map[driver.Key]glfw.Key{
|
||||
driver.Key0: glfw.Key0,
|
||||
driver.Key1: glfw.Key1,
|
||||
driver.Key2: glfw.Key2,
|
||||
driver.Key3: glfw.Key3,
|
||||
driver.Key4: glfw.Key4,
|
||||
driver.Key5: glfw.Key5,
|
||||
driver.Key6: glfw.Key6,
|
||||
driver.Key7: glfw.Key7,
|
||||
driver.Key8: glfw.Key8,
|
||||
driver.Key9: glfw.Key9,
|
||||
driver.KeyA: glfw.KeyA,
|
||||
driver.KeyB: glfw.KeyB,
|
||||
driver.KeyC: glfw.KeyC,
|
||||
driver.KeyD: glfw.KeyD,
|
||||
driver.KeyE: glfw.KeyE,
|
||||
driver.KeyF: glfw.KeyF,
|
||||
driver.KeyG: glfw.KeyG,
|
||||
driver.KeyH: glfw.KeyH,
|
||||
driver.KeyI: glfw.KeyI,
|
||||
driver.KeyJ: glfw.KeyJ,
|
||||
driver.KeyK: glfw.KeyK,
|
||||
driver.KeyL: glfw.KeyL,
|
||||
driver.KeyM: glfw.KeyM,
|
||||
driver.KeyN: glfw.KeyN,
|
||||
driver.KeyO: glfw.KeyO,
|
||||
driver.KeyP: glfw.KeyP,
|
||||
driver.KeyQ: glfw.KeyQ,
|
||||
driver.KeyR: glfw.KeyR,
|
||||
driver.KeyS: glfw.KeyS,
|
||||
driver.KeyT: glfw.KeyT,
|
||||
driver.KeyU: glfw.KeyU,
|
||||
driver.KeyV: glfw.KeyV,
|
||||
driver.KeyW: glfw.KeyW,
|
||||
driver.KeyX: glfw.KeyX,
|
||||
driver.KeyY: glfw.KeyY,
|
||||
driver.KeyZ: glfw.KeyZ,
|
||||
driver.KeyApostrophe: glfw.KeyApostrophe,
|
||||
driver.KeyBackslash: glfw.KeyBackslash,
|
||||
driver.KeyBackspace: glfw.KeyBackspace,
|
||||
driver.KeyCapsLock: glfw.KeyCapsLock,
|
||||
driver.KeyComma: glfw.KeyComma,
|
||||
driver.KeyDelete: glfw.KeyDelete,
|
||||
driver.KeyDown: glfw.KeyDown,
|
||||
driver.KeyEnd: glfw.KeyEnd,
|
||||
driver.KeyEnter: glfw.KeyEnter,
|
||||
driver.KeyEqual: glfw.KeyEqual,
|
||||
driver.KeyEscape: glfw.KeyEscape,
|
||||
driver.KeyF1: glfw.KeyF1,
|
||||
driver.KeyF2: glfw.KeyF2,
|
||||
driver.KeyF3: glfw.KeyF3,
|
||||
driver.KeyF4: glfw.KeyF4,
|
||||
driver.KeyF5: glfw.KeyF5,
|
||||
driver.KeyF6: glfw.KeyF6,
|
||||
driver.KeyF7: glfw.KeyF7,
|
||||
driver.KeyF8: glfw.KeyF8,
|
||||
driver.KeyF9: glfw.KeyF9,
|
||||
driver.KeyF10: glfw.KeyF10,
|
||||
driver.KeyF11: glfw.KeyF11,
|
||||
driver.KeyF12: glfw.KeyF12,
|
||||
driver.KeyGraveAccent: glfw.KeyGraveAccent,
|
||||
driver.KeyHome: glfw.KeyHome,
|
||||
driver.KeyInsert: glfw.KeyInsert,
|
||||
driver.KeyKP0: glfw.KeyKP0,
|
||||
driver.KeyKP1: glfw.KeyKP1,
|
||||
driver.KeyKP2: glfw.KeyKP2,
|
||||
driver.KeyKP3: glfw.KeyKP3,
|
||||
driver.KeyKP4: glfw.KeyKP4,
|
||||
driver.KeyKP5: glfw.KeyKP5,
|
||||
driver.KeyKP6: glfw.KeyKP6,
|
||||
driver.KeyKP7: glfw.KeyKP7,
|
||||
driver.KeyKP8: glfw.KeyKP8,
|
||||
driver.KeyKP9: glfw.KeyKP9,
|
||||
driver.KeyKPAdd: glfw.KeyKPAdd,
|
||||
driver.KeyKPDecimal: glfw.KeyKPDecimal,
|
||||
driver.KeyKPDivide: glfw.KeyKPDivide,
|
||||
driver.KeyKPEnter: glfw.KeyKPEnter,
|
||||
driver.KeyKPEqual: glfw.KeyKPEqual,
|
||||
driver.KeyKPMultiply: glfw.KeyKPMultiply,
|
||||
driver.KeyKPSubtract: glfw.KeyKPSubtract,
|
||||
driver.KeyLeft: glfw.KeyLeft,
|
||||
driver.KeyLeftAlt: glfw.KeyLeftAlt,
|
||||
driver.KeyLeftBracket: glfw.KeyLeftBracket,
|
||||
driver.KeyLeftControl: glfw.KeyLeftControl,
|
||||
driver.KeyLeftShift: glfw.KeyLeftShift,
|
||||
driver.KeyLeftSuper: glfw.KeyLeftSuper,
|
||||
driver.KeyMenu: glfw.KeyMenu,
|
||||
driver.KeyMinus: glfw.KeyMinus,
|
||||
driver.KeyNumLock: glfw.KeyNumLock,
|
||||
driver.KeyPageDown: glfw.KeyPageDown,
|
||||
driver.KeyPageUp: glfw.KeyPageUp,
|
||||
driver.KeyPause: glfw.KeyPause,
|
||||
driver.KeyPeriod: glfw.KeyPeriod,
|
||||
driver.KeyPrintScreen: glfw.KeyPrintScreen,
|
||||
driver.KeyRight: glfw.KeyRight,
|
||||
driver.KeyRightAlt: glfw.KeyRightAlt,
|
||||
driver.KeyRightBracket: glfw.KeyRightBracket,
|
||||
driver.KeyRightControl: glfw.KeyRightControl,
|
||||
driver.KeyRightShift: glfw.KeyRightShift,
|
||||
driver.KeyRightSuper: glfw.KeyRightSuper,
|
||||
driver.KeyScrollLock: glfw.KeyScrollLock,
|
||||
driver.KeySemicolon: glfw.KeySemicolon,
|
||||
driver.KeySlash: glfw.KeySlash,
|
||||
driver.KeySpace: glfw.KeySpace,
|
||||
driver.KeyTab: glfw.KeyTab,
|
||||
driver.KeyUp: glfw.KeyUp,
|
||||
driver.KeyA: glfw.KeyA,
|
||||
driver.KeyAltLeft: glfw.KeyLeftAlt,
|
||||
driver.KeyAltRight: glfw.KeyRightAlt,
|
||||
driver.KeyArrowDown: glfw.KeyDown,
|
||||
driver.KeyArrowLeft: glfw.KeyLeft,
|
||||
driver.KeyArrowRight: glfw.KeyRight,
|
||||
driver.KeyArrowUp: glfw.KeyUp,
|
||||
driver.KeyB: glfw.KeyB,
|
||||
driver.KeyBackquote: glfw.KeyGraveAccent,
|
||||
driver.KeyBackslash: glfw.KeyBackslash,
|
||||
driver.KeyBackspace: glfw.KeyBackspace,
|
||||
driver.KeyBracketLeft: glfw.KeyLeftBracket,
|
||||
driver.KeyBracketRight: glfw.KeyRightBracket,
|
||||
driver.KeyC: glfw.KeyC,
|
||||
driver.KeyCapsLock: glfw.KeyCapsLock,
|
||||
driver.KeyComma: glfw.KeyComma,
|
||||
driver.KeyContextMenu: glfw.KeyMenu,
|
||||
driver.KeyControlLeft: glfw.KeyLeftControl,
|
||||
driver.KeyControlRight: glfw.KeyRightControl,
|
||||
driver.KeyD: glfw.KeyD,
|
||||
driver.KeyDelete: glfw.KeyDelete,
|
||||
driver.KeyDigit0: glfw.Key0,
|
||||
driver.KeyDigit1: glfw.Key1,
|
||||
driver.KeyDigit2: glfw.Key2,
|
||||
driver.KeyDigit3: glfw.Key3,
|
||||
driver.KeyDigit4: glfw.Key4,
|
||||
driver.KeyDigit5: glfw.Key5,
|
||||
driver.KeyDigit6: glfw.Key6,
|
||||
driver.KeyDigit7: glfw.Key7,
|
||||
driver.KeyDigit8: glfw.Key8,
|
||||
driver.KeyDigit9: glfw.Key9,
|
||||
driver.KeyE: glfw.KeyE,
|
||||
driver.KeyEnd: glfw.KeyEnd,
|
||||
driver.KeyEnter: glfw.KeyEnter,
|
||||
driver.KeyEqual: glfw.KeyEqual,
|
||||
driver.KeyEscape: glfw.KeyEscape,
|
||||
driver.KeyF: glfw.KeyF,
|
||||
driver.KeyF1: glfw.KeyF1,
|
||||
driver.KeyF10: glfw.KeyF10,
|
||||
driver.KeyF11: glfw.KeyF11,
|
||||
driver.KeyF12: glfw.KeyF12,
|
||||
driver.KeyF2: glfw.KeyF2,
|
||||
driver.KeyF3: glfw.KeyF3,
|
||||
driver.KeyF4: glfw.KeyF4,
|
||||
driver.KeyF5: glfw.KeyF5,
|
||||
driver.KeyF6: glfw.KeyF6,
|
||||
driver.KeyF7: glfw.KeyF7,
|
||||
driver.KeyF8: glfw.KeyF8,
|
||||
driver.KeyF9: glfw.KeyF9,
|
||||
driver.KeyG: glfw.KeyG,
|
||||
driver.KeyH: glfw.KeyH,
|
||||
driver.KeyHome: glfw.KeyHome,
|
||||
driver.KeyI: glfw.KeyI,
|
||||
driver.KeyInsert: glfw.KeyInsert,
|
||||
driver.KeyJ: glfw.KeyJ,
|
||||
driver.KeyK: glfw.KeyK,
|
||||
driver.KeyL: glfw.KeyL,
|
||||
driver.KeyM: glfw.KeyM,
|
||||
driver.KeyMetaLeft: glfw.KeyLeftSuper,
|
||||
driver.KeyMetaRight: glfw.KeyRightSuper,
|
||||
driver.KeyMinus: glfw.KeyMinus,
|
||||
driver.KeyN: glfw.KeyN,
|
||||
driver.KeyNumLock: glfw.KeyNumLock,
|
||||
driver.KeyNumpad0: glfw.KeyKP0,
|
||||
driver.KeyNumpad1: glfw.KeyKP1,
|
||||
driver.KeyNumpad2: glfw.KeyKP2,
|
||||
driver.KeyNumpad3: glfw.KeyKP3,
|
||||
driver.KeyNumpad4: glfw.KeyKP4,
|
||||
driver.KeyNumpad5: glfw.KeyKP5,
|
||||
driver.KeyNumpad6: glfw.KeyKP6,
|
||||
driver.KeyNumpad7: glfw.KeyKP7,
|
||||
driver.KeyNumpad8: glfw.KeyKP8,
|
||||
driver.KeyNumpad9: glfw.KeyKP9,
|
||||
driver.KeyNumpadAdd: glfw.KeyKPAdd,
|
||||
driver.KeyNumpadDecimal: glfw.KeyKPDecimal,
|
||||
driver.KeyNumpadDivide: glfw.KeyKPDivide,
|
||||
driver.KeyNumpadEnter: glfw.KeyKPEnter,
|
||||
driver.KeyNumpadEqual: glfw.KeyKPEqual,
|
||||
driver.KeyNumpadMultiply: glfw.KeyKPMultiply,
|
||||
driver.KeyNumpadSubtract: glfw.KeyKPSubtract,
|
||||
driver.KeyO: glfw.KeyO,
|
||||
driver.KeyP: glfw.KeyP,
|
||||
driver.KeyPageDown: glfw.KeyPageDown,
|
||||
driver.KeyPageUp: glfw.KeyPageUp,
|
||||
driver.KeyPause: glfw.KeyPause,
|
||||
driver.KeyPeriod: glfw.KeyPeriod,
|
||||
driver.KeyPrintScreen: glfw.KeyPrintScreen,
|
||||
driver.KeyQ: glfw.KeyQ,
|
||||
driver.KeyQuote: glfw.KeyApostrophe,
|
||||
driver.KeyR: glfw.KeyR,
|
||||
driver.KeyS: glfw.KeyS,
|
||||
driver.KeyScrollLock: glfw.KeyScrollLock,
|
||||
driver.KeySemicolon: glfw.KeySemicolon,
|
||||
driver.KeyShiftLeft: glfw.KeyLeftShift,
|
||||
driver.KeyShiftRight: glfw.KeyRightShift,
|
||||
driver.KeySlash: glfw.KeySlash,
|
||||
driver.KeySpace: glfw.KeySpace,
|
||||
driver.KeyT: glfw.KeyT,
|
||||
driver.KeyTab: glfw.KeyTab,
|
||||
driver.KeyU: glfw.KeyU,
|
||||
driver.KeyV: glfw.KeyV,
|
||||
driver.KeyW: glfw.KeyW,
|
||||
driver.KeyX: glfw.KeyX,
|
||||
driver.KeyY: glfw.KeyY,
|
||||
driver.KeyZ: glfw.KeyZ,
|
||||
}
|
||||
|
@ -349,10 +349,10 @@ func (i *Input) updateFromEvent(e js.Value) {
|
||||
c := e.Get("code")
|
||||
if c.Type() != js.TypeString {
|
||||
code := e.Get("keyCode").Int()
|
||||
if edgeKeyCodeToDriverKey[code] == driver.KeyUp ||
|
||||
edgeKeyCodeToDriverKey[code] == driver.KeyDown ||
|
||||
edgeKeyCodeToDriverKey[code] == driver.KeyLeft ||
|
||||
edgeKeyCodeToDriverKey[code] == driver.KeyRight ||
|
||||
if edgeKeyCodeToDriverKey[code] == driver.KeyArrowUp ||
|
||||
edgeKeyCodeToDriverKey[code] == driver.KeyArrowDown ||
|
||||
edgeKeyCodeToDriverKey[code] == driver.KeyArrowLeft ||
|
||||
edgeKeyCodeToDriverKey[code] == driver.KeyArrowRight ||
|
||||
edgeKeyCodeToDriverKey[code] == driver.KeyBackspace ||
|
||||
edgeKeyCodeToDriverKey[code] == driver.KeyTab {
|
||||
e.Call("preventDefault")
|
||||
@ -360,10 +360,10 @@ func (i *Input) updateFromEvent(e js.Value) {
|
||||
i.keyDownEdge(code)
|
||||
return
|
||||
}
|
||||
if jsutil.Equal(c, driverKeyToJSKey[driver.KeyUp]) ||
|
||||
jsutil.Equal(c, driverKeyToJSKey[driver.KeyDown]) ||
|
||||
jsutil.Equal(c, driverKeyToJSKey[driver.KeyLeft]) ||
|
||||
jsutil.Equal(c, driverKeyToJSKey[driver.KeyRight]) ||
|
||||
if jsutil.Equal(c, driverKeyToJSKey[driver.KeyArrowUp]) ||
|
||||
jsutil.Equal(c, driverKeyToJSKey[driver.KeyArrowDown]) ||
|
||||
jsutil.Equal(c, driverKeyToJSKey[driver.KeyArrowLeft]) ||
|
||||
jsutil.Equal(c, driverKeyToJSKey[driver.KeyArrowRight]) ||
|
||||
jsutil.Equal(c, driverKeyToJSKey[driver.KeyBackspace]) ||
|
||||
jsutil.Equal(c, driverKeyToJSKey[driver.KeyTab]) {
|
||||
e.Call("preventDefault")
|
||||
|
@ -23,120 +23,120 @@ import (
|
||||
)
|
||||
|
||||
var driverKeyToJSKey = map[driver.Key]js.Value{
|
||||
driver.Key0: js.ValueOf("Digit0"),
|
||||
driver.Key1: js.ValueOf("Digit1"),
|
||||
driver.Key2: js.ValueOf("Digit2"),
|
||||
driver.Key3: js.ValueOf("Digit3"),
|
||||
driver.Key4: js.ValueOf("Digit4"),
|
||||
driver.Key5: js.ValueOf("Digit5"),
|
||||
driver.Key6: js.ValueOf("Digit6"),
|
||||
driver.Key7: js.ValueOf("Digit7"),
|
||||
driver.Key8: js.ValueOf("Digit8"),
|
||||
driver.Key9: js.ValueOf("Digit9"),
|
||||
driver.KeyA: js.ValueOf("KeyA"),
|
||||
driver.KeyApostrophe: js.ValueOf("Quote"),
|
||||
driver.KeyB: js.ValueOf("KeyB"),
|
||||
driver.KeyBackslash: js.ValueOf("Backslash"),
|
||||
driver.KeyBackspace: js.ValueOf("Backspace"),
|
||||
driver.KeyC: js.ValueOf("KeyC"),
|
||||
driver.KeyCapsLock: js.ValueOf("CapsLock"),
|
||||
driver.KeyComma: js.ValueOf("Comma"),
|
||||
driver.KeyD: js.ValueOf("KeyD"),
|
||||
driver.KeyDelete: js.ValueOf("Delete"),
|
||||
driver.KeyDown: js.ValueOf("ArrowDown"),
|
||||
driver.KeyE: js.ValueOf("KeyE"),
|
||||
driver.KeyEnd: js.ValueOf("End"),
|
||||
driver.KeyEnter: js.ValueOf("Enter"),
|
||||
driver.KeyEqual: js.ValueOf("Equal"),
|
||||
driver.KeyEscape: js.ValueOf("Escape"),
|
||||
driver.KeyF: js.ValueOf("KeyF"),
|
||||
driver.KeyF1: js.ValueOf("F1"),
|
||||
driver.KeyF10: js.ValueOf("F10"),
|
||||
driver.KeyF11: js.ValueOf("F11"),
|
||||
driver.KeyF12: js.ValueOf("F12"),
|
||||
driver.KeyF2: js.ValueOf("F2"),
|
||||
driver.KeyF3: js.ValueOf("F3"),
|
||||
driver.KeyF4: js.ValueOf("F4"),
|
||||
driver.KeyF5: js.ValueOf("F5"),
|
||||
driver.KeyF6: js.ValueOf("F6"),
|
||||
driver.KeyF7: js.ValueOf("F7"),
|
||||
driver.KeyF8: js.ValueOf("F8"),
|
||||
driver.KeyF9: js.ValueOf("F9"),
|
||||
driver.KeyG: js.ValueOf("KeyG"),
|
||||
driver.KeyGraveAccent: js.ValueOf("Backquote"),
|
||||
driver.KeyH: js.ValueOf("KeyH"),
|
||||
driver.KeyHome: js.ValueOf("Home"),
|
||||
driver.KeyI: js.ValueOf("KeyI"),
|
||||
driver.KeyInsert: js.ValueOf("Insert"),
|
||||
driver.KeyJ: js.ValueOf("KeyJ"),
|
||||
driver.KeyK: js.ValueOf("KeyK"),
|
||||
driver.KeyKP0: js.ValueOf("Numpad0"),
|
||||
driver.KeyKP1: js.ValueOf("Numpad1"),
|
||||
driver.KeyKP2: js.ValueOf("Numpad2"),
|
||||
driver.KeyKP3: js.ValueOf("Numpad3"),
|
||||
driver.KeyKP4: js.ValueOf("Numpad4"),
|
||||
driver.KeyKP5: js.ValueOf("Numpad5"),
|
||||
driver.KeyKP6: js.ValueOf("Numpad6"),
|
||||
driver.KeyKP7: js.ValueOf("Numpad7"),
|
||||
driver.KeyKP8: js.ValueOf("Numpad8"),
|
||||
driver.KeyKP9: js.ValueOf("Numpad9"),
|
||||
driver.KeyKPAdd: js.ValueOf("NumpadAdd"),
|
||||
driver.KeyKPDecimal: js.ValueOf("NumpadDecimal"),
|
||||
driver.KeyKPDivide: js.ValueOf("NumpadDivide"),
|
||||
driver.KeyKPEnter: js.ValueOf("NumpadEnter"),
|
||||
driver.KeyKPEqual: js.ValueOf("NumpadEqual"),
|
||||
driver.KeyKPMultiply: js.ValueOf("NumpadMultiply"),
|
||||
driver.KeyKPSubtract: js.ValueOf("NumpadSubtract"),
|
||||
driver.KeyL: js.ValueOf("KeyL"),
|
||||
driver.KeyLeft: js.ValueOf("ArrowLeft"),
|
||||
driver.KeyLeftAlt: js.ValueOf("AltLeft"),
|
||||
driver.KeyLeftBracket: js.ValueOf("BracketLeft"),
|
||||
driver.KeyLeftControl: js.ValueOf("ControlLeft"),
|
||||
driver.KeyLeftShift: js.ValueOf("ShiftLeft"),
|
||||
driver.KeyLeftSuper: js.ValueOf("MetaLeft"),
|
||||
driver.KeyM: js.ValueOf("KeyM"),
|
||||
driver.KeyMenu: js.ValueOf("ContextMenu"),
|
||||
driver.KeyMinus: js.ValueOf("Minus"),
|
||||
driver.KeyN: js.ValueOf("KeyN"),
|
||||
driver.KeyNumLock: js.ValueOf("NumLock"),
|
||||
driver.KeyO: js.ValueOf("KeyO"),
|
||||
driver.KeyP: js.ValueOf("KeyP"),
|
||||
driver.KeyPageDown: js.ValueOf("PageDown"),
|
||||
driver.KeyPageUp: js.ValueOf("PageUp"),
|
||||
driver.KeyPause: js.ValueOf("Pause"),
|
||||
driver.KeyPeriod: js.ValueOf("Period"),
|
||||
driver.KeyPrintScreen: js.ValueOf("PrintScreen"),
|
||||
driver.KeyQ: js.ValueOf("KeyQ"),
|
||||
driver.KeyR: js.ValueOf("KeyR"),
|
||||
driver.KeyRight: js.ValueOf("ArrowRight"),
|
||||
driver.KeyRightAlt: js.ValueOf("AltRight"),
|
||||
driver.KeyRightBracket: js.ValueOf("BracketRight"),
|
||||
driver.KeyRightControl: js.ValueOf("ControlRight"),
|
||||
driver.KeyRightShift: js.ValueOf("ShiftRight"),
|
||||
driver.KeyRightSuper: js.ValueOf("MetaRight"),
|
||||
driver.KeyS: js.ValueOf("KeyS"),
|
||||
driver.KeyScrollLock: js.ValueOf("ScrollLock"),
|
||||
driver.KeySemicolon: js.ValueOf("Semicolon"),
|
||||
driver.KeySlash: js.ValueOf("Slash"),
|
||||
driver.KeySpace: js.ValueOf("Space"),
|
||||
driver.KeyT: js.ValueOf("KeyT"),
|
||||
driver.KeyTab: js.ValueOf("Tab"),
|
||||
driver.KeyU: js.ValueOf("KeyU"),
|
||||
driver.KeyUp: js.ValueOf("ArrowUp"),
|
||||
driver.KeyV: js.ValueOf("KeyV"),
|
||||
driver.KeyW: js.ValueOf("KeyW"),
|
||||
driver.KeyX: js.ValueOf("KeyX"),
|
||||
driver.KeyY: js.ValueOf("KeyY"),
|
||||
driver.KeyZ: js.ValueOf("KeyZ"),
|
||||
driver.KeyA: js.ValueOf("KeyA"),
|
||||
driver.KeyAltLeft: js.ValueOf("AltLeft"),
|
||||
driver.KeyAltRight: js.ValueOf("AltRight"),
|
||||
driver.KeyArrowDown: js.ValueOf("ArrowDown"),
|
||||
driver.KeyArrowLeft: js.ValueOf("ArrowLeft"),
|
||||
driver.KeyArrowRight: js.ValueOf("ArrowRight"),
|
||||
driver.KeyArrowUp: js.ValueOf("ArrowUp"),
|
||||
driver.KeyB: js.ValueOf("KeyB"),
|
||||
driver.KeyBackquote: js.ValueOf("Backquote"),
|
||||
driver.KeyBackslash: js.ValueOf("Backslash"),
|
||||
driver.KeyBackspace: js.ValueOf("Backspace"),
|
||||
driver.KeyBracketLeft: js.ValueOf("BracketLeft"),
|
||||
driver.KeyBracketRight: js.ValueOf("BracketRight"),
|
||||
driver.KeyC: js.ValueOf("KeyC"),
|
||||
driver.KeyCapsLock: js.ValueOf("CapsLock"),
|
||||
driver.KeyComma: js.ValueOf("Comma"),
|
||||
driver.KeyContextMenu: js.ValueOf("ContextMenu"),
|
||||
driver.KeyControlLeft: js.ValueOf("ControlLeft"),
|
||||
driver.KeyControlRight: js.ValueOf("ControlRight"),
|
||||
driver.KeyD: js.ValueOf("KeyD"),
|
||||
driver.KeyDelete: js.ValueOf("Delete"),
|
||||
driver.KeyDigit0: js.ValueOf("Digit0"),
|
||||
driver.KeyDigit1: js.ValueOf("Digit1"),
|
||||
driver.KeyDigit2: js.ValueOf("Digit2"),
|
||||
driver.KeyDigit3: js.ValueOf("Digit3"),
|
||||
driver.KeyDigit4: js.ValueOf("Digit4"),
|
||||
driver.KeyDigit5: js.ValueOf("Digit5"),
|
||||
driver.KeyDigit6: js.ValueOf("Digit6"),
|
||||
driver.KeyDigit7: js.ValueOf("Digit7"),
|
||||
driver.KeyDigit8: js.ValueOf("Digit8"),
|
||||
driver.KeyDigit9: js.ValueOf("Digit9"),
|
||||
driver.KeyE: js.ValueOf("KeyE"),
|
||||
driver.KeyEnd: js.ValueOf("End"),
|
||||
driver.KeyEnter: js.ValueOf("Enter"),
|
||||
driver.KeyEqual: js.ValueOf("Equal"),
|
||||
driver.KeyEscape: js.ValueOf("Escape"),
|
||||
driver.KeyF: js.ValueOf("KeyF"),
|
||||
driver.KeyF1: js.ValueOf("F1"),
|
||||
driver.KeyF10: js.ValueOf("F10"),
|
||||
driver.KeyF11: js.ValueOf("F11"),
|
||||
driver.KeyF12: js.ValueOf("F12"),
|
||||
driver.KeyF2: js.ValueOf("F2"),
|
||||
driver.KeyF3: js.ValueOf("F3"),
|
||||
driver.KeyF4: js.ValueOf("F4"),
|
||||
driver.KeyF5: js.ValueOf("F5"),
|
||||
driver.KeyF6: js.ValueOf("F6"),
|
||||
driver.KeyF7: js.ValueOf("F7"),
|
||||
driver.KeyF8: js.ValueOf("F8"),
|
||||
driver.KeyF9: js.ValueOf("F9"),
|
||||
driver.KeyG: js.ValueOf("KeyG"),
|
||||
driver.KeyH: js.ValueOf("KeyH"),
|
||||
driver.KeyHome: js.ValueOf("Home"),
|
||||
driver.KeyI: js.ValueOf("KeyI"),
|
||||
driver.KeyInsert: js.ValueOf("Insert"),
|
||||
driver.KeyJ: js.ValueOf("KeyJ"),
|
||||
driver.KeyK: js.ValueOf("KeyK"),
|
||||
driver.KeyL: js.ValueOf("KeyL"),
|
||||
driver.KeyM: js.ValueOf("KeyM"),
|
||||
driver.KeyMetaLeft: js.ValueOf("MetaLeft"),
|
||||
driver.KeyMetaRight: js.ValueOf("MetaRight"),
|
||||
driver.KeyMinus: js.ValueOf("Minus"),
|
||||
driver.KeyN: js.ValueOf("KeyN"),
|
||||
driver.KeyNumLock: js.ValueOf("NumLock"),
|
||||
driver.KeyNumpad0: js.ValueOf("Numpad0"),
|
||||
driver.KeyNumpad1: js.ValueOf("Numpad1"),
|
||||
driver.KeyNumpad2: js.ValueOf("Numpad2"),
|
||||
driver.KeyNumpad3: js.ValueOf("Numpad3"),
|
||||
driver.KeyNumpad4: js.ValueOf("Numpad4"),
|
||||
driver.KeyNumpad5: js.ValueOf("Numpad5"),
|
||||
driver.KeyNumpad6: js.ValueOf("Numpad6"),
|
||||
driver.KeyNumpad7: js.ValueOf("Numpad7"),
|
||||
driver.KeyNumpad8: js.ValueOf("Numpad8"),
|
||||
driver.KeyNumpad9: js.ValueOf("Numpad9"),
|
||||
driver.KeyNumpadAdd: js.ValueOf("NumpadAdd"),
|
||||
driver.KeyNumpadDecimal: js.ValueOf("NumpadDecimal"),
|
||||
driver.KeyNumpadDivide: js.ValueOf("NumpadDivide"),
|
||||
driver.KeyNumpadEnter: js.ValueOf("NumpadEnter"),
|
||||
driver.KeyNumpadEqual: js.ValueOf("NumpadEqual"),
|
||||
driver.KeyNumpadMultiply: js.ValueOf("NumpadMultiply"),
|
||||
driver.KeyNumpadSubtract: js.ValueOf("NumpadSubtract"),
|
||||
driver.KeyO: js.ValueOf("KeyO"),
|
||||
driver.KeyP: js.ValueOf("KeyP"),
|
||||
driver.KeyPageDown: js.ValueOf("PageDown"),
|
||||
driver.KeyPageUp: js.ValueOf("PageUp"),
|
||||
driver.KeyPause: js.ValueOf("Pause"),
|
||||
driver.KeyPeriod: js.ValueOf("Period"),
|
||||
driver.KeyPrintScreen: js.ValueOf("PrintScreen"),
|
||||
driver.KeyQ: js.ValueOf("KeyQ"),
|
||||
driver.KeyQuote: js.ValueOf("Quote"),
|
||||
driver.KeyR: js.ValueOf("KeyR"),
|
||||
driver.KeyS: js.ValueOf("KeyS"),
|
||||
driver.KeyScrollLock: js.ValueOf("ScrollLock"),
|
||||
driver.KeySemicolon: js.ValueOf("Semicolon"),
|
||||
driver.KeyShiftLeft: js.ValueOf("ShiftLeft"),
|
||||
driver.KeyShiftRight: js.ValueOf("ShiftRight"),
|
||||
driver.KeySlash: js.ValueOf("Slash"),
|
||||
driver.KeySpace: js.ValueOf("Space"),
|
||||
driver.KeyT: js.ValueOf("KeyT"),
|
||||
driver.KeyTab: js.ValueOf("Tab"),
|
||||
driver.KeyU: js.ValueOf("KeyU"),
|
||||
driver.KeyV: js.ValueOf("KeyV"),
|
||||
driver.KeyW: js.ValueOf("KeyW"),
|
||||
driver.KeyX: js.ValueOf("KeyX"),
|
||||
driver.KeyY: js.ValueOf("KeyY"),
|
||||
driver.KeyZ: js.ValueOf("KeyZ"),
|
||||
}
|
||||
|
||||
var edgeKeyCodeToDriverKey = map[int]driver.Key{
|
||||
8: driver.KeyBackspace,
|
||||
9: driver.KeyTab,
|
||||
13: driver.KeyEnter,
|
||||
16: driver.KeyLeftShift,
|
||||
17: driver.KeyLeftControl,
|
||||
18: driver.KeyLeftAlt,
|
||||
16: driver.KeyShiftLeft,
|
||||
17: driver.KeyControlLeft,
|
||||
18: driver.KeyAltLeft,
|
||||
19: driver.KeyPause,
|
||||
20: driver.KeyCapsLock,
|
||||
27: driver.KeyEscape,
|
||||
@ -145,22 +145,22 @@ var edgeKeyCodeToDriverKey = map[int]driver.Key{
|
||||
34: driver.KeyPageDown,
|
||||
35: driver.KeyEnd,
|
||||
36: driver.KeyHome,
|
||||
37: driver.KeyLeft,
|
||||
38: driver.KeyUp,
|
||||
39: driver.KeyRight,
|
||||
40: driver.KeyDown,
|
||||
37: driver.KeyArrowLeft,
|
||||
38: driver.KeyArrowUp,
|
||||
39: driver.KeyArrowRight,
|
||||
40: driver.KeyArrowDown,
|
||||
45: driver.KeyInsert,
|
||||
46: driver.KeyDelete,
|
||||
48: driver.Key0,
|
||||
49: driver.Key1,
|
||||
50: driver.Key2,
|
||||
51: driver.Key3,
|
||||
52: driver.Key4,
|
||||
53: driver.Key5,
|
||||
54: driver.Key6,
|
||||
55: driver.Key7,
|
||||
56: driver.Key8,
|
||||
57: driver.Key9,
|
||||
48: driver.KeyDigit0,
|
||||
49: driver.KeyDigit1,
|
||||
50: driver.KeyDigit2,
|
||||
51: driver.KeyDigit3,
|
||||
52: driver.KeyDigit4,
|
||||
53: driver.KeyDigit5,
|
||||
54: driver.KeyDigit6,
|
||||
55: driver.KeyDigit7,
|
||||
56: driver.KeyDigit8,
|
||||
57: driver.KeyDigit9,
|
||||
65: driver.KeyA,
|
||||
66: driver.KeyB,
|
||||
67: driver.KeyC,
|
||||
@ -187,24 +187,24 @@ var edgeKeyCodeToDriverKey = map[int]driver.Key{
|
||||
88: driver.KeyX,
|
||||
89: driver.KeyY,
|
||||
90: driver.KeyZ,
|
||||
91: driver.KeyLeftSuper,
|
||||
92: driver.KeyRightSuper,
|
||||
93: driver.KeyMenu,
|
||||
96: driver.KeyKP0,
|
||||
97: driver.KeyKP1,
|
||||
98: driver.KeyKP2,
|
||||
99: driver.KeyKP3,
|
||||
100: driver.KeyKP4,
|
||||
101: driver.KeyKP5,
|
||||
102: driver.KeyKP6,
|
||||
103: driver.KeyKP7,
|
||||
104: driver.KeyKP8,
|
||||
105: driver.KeyKP9,
|
||||
106: driver.KeyKPMultiply,
|
||||
107: driver.KeyKPAdd,
|
||||
109: driver.KeyKPSubtract,
|
||||
110: driver.KeyKPDecimal,
|
||||
111: driver.KeyKPDivide,
|
||||
91: driver.KeyMetaLeft,
|
||||
92: driver.KeyMetaRight,
|
||||
93: driver.KeyContextMenu,
|
||||
96: driver.KeyNumpad0,
|
||||
97: driver.KeyNumpad1,
|
||||
98: driver.KeyNumpad2,
|
||||
99: driver.KeyNumpad3,
|
||||
100: driver.KeyNumpad4,
|
||||
101: driver.KeyNumpad5,
|
||||
102: driver.KeyNumpad6,
|
||||
103: driver.KeyNumpad7,
|
||||
104: driver.KeyNumpad8,
|
||||
105: driver.KeyNumpad9,
|
||||
106: driver.KeyNumpadMultiply,
|
||||
107: driver.KeyNumpadAdd,
|
||||
109: driver.KeyNumpadSubtract,
|
||||
110: driver.KeyNumpadDecimal,
|
||||
111: driver.KeyNumpadDivide,
|
||||
112: driver.KeyF1,
|
||||
113: driver.KeyF2,
|
||||
114: driver.KeyF3,
|
||||
@ -225,9 +225,9 @@ var edgeKeyCodeToDriverKey = map[int]driver.Key{
|
||||
189: driver.KeyMinus,
|
||||
190: driver.KeyPeriod,
|
||||
191: driver.KeySlash,
|
||||
192: driver.KeyGraveAccent,
|
||||
219: driver.KeyLeftBracket,
|
||||
192: driver.KeyBackquote,
|
||||
219: driver.KeyBracketLeft,
|
||||
220: driver.KeyBackslash,
|
||||
221: driver.KeyRightBracket,
|
||||
222: driver.KeyApostrophe,
|
||||
221: driver.KeyBracketRight,
|
||||
222: driver.KeyQuote,
|
||||
}
|
||||
|
@ -49,16 +49,16 @@ var gbuildKeyToDriverKey = map[key.Code]driver.Key{
|
||||
key.CodeX: driver.KeyX,
|
||||
key.CodeY: driver.KeyY,
|
||||
key.CodeZ: driver.KeyZ,
|
||||
key.Code1: driver.Key1,
|
||||
key.Code2: driver.Key2,
|
||||
key.Code3: driver.Key3,
|
||||
key.Code4: driver.Key4,
|
||||
key.Code5: driver.Key5,
|
||||
key.Code6: driver.Key6,
|
||||
key.Code7: driver.Key7,
|
||||
key.Code8: driver.Key8,
|
||||
key.Code9: driver.Key9,
|
||||
key.Code0: driver.Key0,
|
||||
key.Code1: driver.KeyDigit1,
|
||||
key.Code2: driver.KeyDigit2,
|
||||
key.Code3: driver.KeyDigit3,
|
||||
key.Code4: driver.KeyDigit4,
|
||||
key.Code5: driver.KeyDigit5,
|
||||
key.Code6: driver.KeyDigit6,
|
||||
key.Code7: driver.KeyDigit7,
|
||||
key.Code8: driver.KeyDigit8,
|
||||
key.Code9: driver.KeyDigit9,
|
||||
key.Code0: driver.KeyDigit0,
|
||||
key.CodeReturnEnter: driver.KeyEnter,
|
||||
key.CodeEscape: driver.KeyEscape,
|
||||
key.CodeDeleteBackspace: driver.KeyBackspace,
|
||||
@ -66,12 +66,12 @@ var gbuildKeyToDriverKey = map[key.Code]driver.Key{
|
||||
key.CodeSpacebar: driver.KeySpace,
|
||||
key.CodeHyphenMinus: driver.KeyMinus,
|
||||
key.CodeEqualSign: driver.KeyEqual,
|
||||
key.CodeLeftSquareBracket: driver.KeyLeftBracket,
|
||||
key.CodeRightSquareBracket: driver.KeyRightBracket,
|
||||
key.CodeLeftSquareBracket: driver.KeyBracketLeft,
|
||||
key.CodeRightSquareBracket: driver.KeyBracketRight,
|
||||
key.CodeBackslash: driver.KeyBackslash,
|
||||
key.CodeSemicolon: driver.KeySemicolon,
|
||||
key.CodeApostrophe: driver.KeyApostrophe,
|
||||
key.CodeGraveAccent: driver.KeyGraveAccent,
|
||||
key.CodeApostrophe: driver.KeyQuote,
|
||||
key.CodeGraveAccent: driver.KeyBackquote,
|
||||
key.CodeComma: driver.KeyComma,
|
||||
key.CodeFullStop: driver.KeyPeriod,
|
||||
key.CodeSlash: driver.KeySlash,
|
||||
@ -95,34 +95,34 @@ var gbuildKeyToDriverKey = map[key.Code]driver.Key{
|
||||
key.CodeDeleteForward: driver.KeyDelete,
|
||||
key.CodeEnd: driver.KeyEnd,
|
||||
key.CodePageDown: driver.KeyPageDown,
|
||||
key.CodeRightArrow: driver.KeyRight,
|
||||
key.CodeLeftArrow: driver.KeyLeft,
|
||||
key.CodeDownArrow: driver.KeyDown,
|
||||
key.CodeUpArrow: driver.KeyUp,
|
||||
key.CodeRightArrow: driver.KeyArrowRight,
|
||||
key.CodeLeftArrow: driver.KeyArrowLeft,
|
||||
key.CodeDownArrow: driver.KeyArrowDown,
|
||||
key.CodeUpArrow: driver.KeyArrowUp,
|
||||
key.CodeKeypadNumLock: driver.KeyNumLock,
|
||||
key.CodeKeypadSlash: driver.KeyKPDivide,
|
||||
key.CodeKeypadAsterisk: driver.KeyKPMultiply,
|
||||
key.CodeKeypadHyphenMinus: driver.KeyKPSubtract,
|
||||
key.CodeKeypadPlusSign: driver.KeyKPAdd,
|
||||
key.CodeKeypadEnter: driver.KeyKPEnter,
|
||||
key.CodeKeypad1: driver.KeyKP1,
|
||||
key.CodeKeypad2: driver.KeyKP2,
|
||||
key.CodeKeypad3: driver.KeyKP3,
|
||||
key.CodeKeypad4: driver.KeyKP4,
|
||||
key.CodeKeypad5: driver.KeyKP5,
|
||||
key.CodeKeypad6: driver.KeyKP6,
|
||||
key.CodeKeypad7: driver.KeyKP7,
|
||||
key.CodeKeypad8: driver.KeyKP8,
|
||||
key.CodeKeypad9: driver.KeyKP9,
|
||||
key.CodeKeypad0: driver.KeyKP0,
|
||||
key.CodeKeypadFullStop: driver.KeyKPDecimal,
|
||||
key.CodeKeypadEqualSign: driver.KeyKPEqual,
|
||||
key.CodeLeftControl: driver.KeyLeftControl,
|
||||
key.CodeLeftShift: driver.KeyLeftShift,
|
||||
key.CodeLeftAlt: driver.KeyLeftAlt,
|
||||
key.CodeLeftGUI: driver.KeyLeftSuper,
|
||||
key.CodeRightControl: driver.KeyRightControl,
|
||||
key.CodeRightShift: driver.KeyRightShift,
|
||||
key.CodeRightAlt: driver.KeyRightAlt,
|
||||
key.CodeRightGUI: driver.KeyRightSuper,
|
||||
key.CodeKeypadSlash: driver.KeyNumpadDivide,
|
||||
key.CodeKeypadAsterisk: driver.KeyNumpadMultiply,
|
||||
key.CodeKeypadHyphenMinus: driver.KeyNumpadSubtract,
|
||||
key.CodeKeypadPlusSign: driver.KeyNumpadAdd,
|
||||
key.CodeKeypadEnter: driver.KeyNumpadEnter,
|
||||
key.CodeKeypad1: driver.KeyNumpad1,
|
||||
key.CodeKeypad2: driver.KeyNumpad2,
|
||||
key.CodeKeypad3: driver.KeyNumpad3,
|
||||
key.CodeKeypad4: driver.KeyNumpad4,
|
||||
key.CodeKeypad5: driver.KeyNumpad5,
|
||||
key.CodeKeypad6: driver.KeyNumpad6,
|
||||
key.CodeKeypad7: driver.KeyNumpad7,
|
||||
key.CodeKeypad8: driver.KeyNumpad8,
|
||||
key.CodeKeypad9: driver.KeyNumpad9,
|
||||
key.CodeKeypad0: driver.KeyNumpad0,
|
||||
key.CodeKeypadFullStop: driver.KeyNumpadDecimal,
|
||||
key.CodeKeypadEqualSign: driver.KeyNumpadEqual,
|
||||
key.CodeLeftControl: driver.KeyControlLeft,
|
||||
key.CodeLeftShift: driver.KeyShiftLeft,
|
||||
key.CodeLeftAlt: driver.KeyAltLeft,
|
||||
key.CodeLeftGUI: driver.KeyMetaLeft,
|
||||
key.CodeRightControl: driver.KeyControlRight,
|
||||
key.CodeRightShift: driver.KeyShiftRight,
|
||||
key.CodeRightAlt: driver.KeyAltRight,
|
||||
key.CodeRightGUI: driver.KeyMetaRight,
|
||||
}
|
||||
|
716
keys.go
716
keys.go
@ -29,140 +29,158 @@ type Key int
|
||||
|
||||
// Keys.
|
||||
const (
|
||||
Key0 Key = Key(driver.Key0)
|
||||
Key1 Key = Key(driver.Key1)
|
||||
Key2 Key = Key(driver.Key2)
|
||||
Key3 Key = Key(driver.Key3)
|
||||
Key4 Key = Key(driver.Key4)
|
||||
Key5 Key = Key(driver.Key5)
|
||||
Key6 Key = Key(driver.Key6)
|
||||
Key7 Key = Key(driver.Key7)
|
||||
Key8 Key = Key(driver.Key8)
|
||||
Key9 Key = Key(driver.Key9)
|
||||
KeyA Key = Key(driver.KeyA)
|
||||
KeyB Key = Key(driver.KeyB)
|
||||
KeyC Key = Key(driver.KeyC)
|
||||
KeyD Key = Key(driver.KeyD)
|
||||
KeyE Key = Key(driver.KeyE)
|
||||
KeyF Key = Key(driver.KeyF)
|
||||
KeyG Key = Key(driver.KeyG)
|
||||
KeyH Key = Key(driver.KeyH)
|
||||
KeyI Key = Key(driver.KeyI)
|
||||
KeyJ Key = Key(driver.KeyJ)
|
||||
KeyK Key = Key(driver.KeyK)
|
||||
KeyL Key = Key(driver.KeyL)
|
||||
KeyM Key = Key(driver.KeyM)
|
||||
KeyN Key = Key(driver.KeyN)
|
||||
KeyO Key = Key(driver.KeyO)
|
||||
KeyP Key = Key(driver.KeyP)
|
||||
KeyQ Key = Key(driver.KeyQ)
|
||||
KeyR Key = Key(driver.KeyR)
|
||||
KeyS Key = Key(driver.KeyS)
|
||||
KeyT Key = Key(driver.KeyT)
|
||||
KeyU Key = Key(driver.KeyU)
|
||||
KeyV Key = Key(driver.KeyV)
|
||||
KeyW Key = Key(driver.KeyW)
|
||||
KeyX Key = Key(driver.KeyX)
|
||||
KeyY Key = Key(driver.KeyY)
|
||||
KeyZ Key = Key(driver.KeyZ)
|
||||
KeyApostrophe Key = Key(driver.KeyApostrophe)
|
||||
KeyBackslash Key = Key(driver.KeyBackslash)
|
||||
KeyBackspace Key = Key(driver.KeyBackspace)
|
||||
KeyCapsLock Key = Key(driver.KeyCapsLock)
|
||||
KeyComma Key = Key(driver.KeyComma)
|
||||
KeyDelete Key = Key(driver.KeyDelete)
|
||||
KeyDown Key = Key(driver.KeyDown)
|
||||
KeyEnd Key = Key(driver.KeyEnd)
|
||||
KeyEnter Key = Key(driver.KeyEnter)
|
||||
KeyEqual Key = Key(driver.KeyEqual)
|
||||
KeyEscape Key = Key(driver.KeyEscape)
|
||||
KeyF1 Key = Key(driver.KeyF1)
|
||||
KeyF2 Key = Key(driver.KeyF2)
|
||||
KeyF3 Key = Key(driver.KeyF3)
|
||||
KeyF4 Key = Key(driver.KeyF4)
|
||||
KeyF5 Key = Key(driver.KeyF5)
|
||||
KeyF6 Key = Key(driver.KeyF6)
|
||||
KeyF7 Key = Key(driver.KeyF7)
|
||||
KeyF8 Key = Key(driver.KeyF8)
|
||||
KeyF9 Key = Key(driver.KeyF9)
|
||||
KeyF10 Key = Key(driver.KeyF10)
|
||||
KeyF11 Key = Key(driver.KeyF11)
|
||||
KeyF12 Key = Key(driver.KeyF12)
|
||||
KeyGraveAccent Key = Key(driver.KeyGraveAccent)
|
||||
KeyHome Key = Key(driver.KeyHome)
|
||||
KeyInsert Key = Key(driver.KeyInsert)
|
||||
KeyKP0 Key = Key(driver.KeyKP0)
|
||||
KeyKP1 Key = Key(driver.KeyKP1)
|
||||
KeyKP2 Key = Key(driver.KeyKP2)
|
||||
KeyKP3 Key = Key(driver.KeyKP3)
|
||||
KeyKP4 Key = Key(driver.KeyKP4)
|
||||
KeyKP5 Key = Key(driver.KeyKP5)
|
||||
KeyKP6 Key = Key(driver.KeyKP6)
|
||||
KeyKP7 Key = Key(driver.KeyKP7)
|
||||
KeyKP8 Key = Key(driver.KeyKP8)
|
||||
KeyKP9 Key = Key(driver.KeyKP9)
|
||||
KeyKPAdd Key = Key(driver.KeyKPAdd)
|
||||
KeyKPDecimal Key = Key(driver.KeyKPDecimal)
|
||||
KeyKPDivide Key = Key(driver.KeyKPDivide)
|
||||
KeyKPEnter Key = Key(driver.KeyKPEnter)
|
||||
KeyKPEqual Key = Key(driver.KeyKPEqual)
|
||||
KeyKPMultiply Key = Key(driver.KeyKPMultiply)
|
||||
KeyKPSubtract Key = Key(driver.KeyKPSubtract)
|
||||
KeyLeft Key = Key(driver.KeyLeft)
|
||||
KeyLeftAlt Key = Key(driver.KeyLeftAlt)
|
||||
KeyLeftBracket Key = Key(driver.KeyLeftBracket)
|
||||
KeyLeftControl Key = Key(driver.KeyLeftControl)
|
||||
KeyLeftShift Key = Key(driver.KeyLeftShift)
|
||||
KeyLeftSuper Key = Key(driver.KeyLeftSuper)
|
||||
KeyMenu Key = Key(driver.KeyMenu)
|
||||
KeyMinus Key = Key(driver.KeyMinus)
|
||||
KeyNumLock Key = Key(driver.KeyNumLock)
|
||||
KeyPageDown Key = Key(driver.KeyPageDown)
|
||||
KeyPageUp Key = Key(driver.KeyPageUp)
|
||||
KeyPause Key = Key(driver.KeyPause)
|
||||
KeyPeriod Key = Key(driver.KeyPeriod)
|
||||
KeyPrintScreen Key = Key(driver.KeyPrintScreen)
|
||||
KeyRight Key = Key(driver.KeyRight)
|
||||
KeyRightAlt Key = Key(driver.KeyRightAlt)
|
||||
KeyRightBracket Key = Key(driver.KeyRightBracket)
|
||||
KeyRightControl Key = Key(driver.KeyRightControl)
|
||||
KeyRightShift Key = Key(driver.KeyRightShift)
|
||||
KeyRightSuper Key = Key(driver.KeyRightSuper)
|
||||
KeyScrollLock Key = Key(driver.KeyScrollLock)
|
||||
KeySemicolon Key = Key(driver.KeySemicolon)
|
||||
KeySlash Key = Key(driver.KeySlash)
|
||||
KeySpace Key = Key(driver.KeySpace)
|
||||
KeyTab Key = Key(driver.KeyTab)
|
||||
KeyUp Key = Key(driver.KeyUp)
|
||||
KeyAlt Key = Key(driver.KeyReserved0)
|
||||
KeyControl Key = Key(driver.KeyReserved1)
|
||||
KeyShift Key = Key(driver.KeyReserved2)
|
||||
KeySuper Key = Key(driver.KeyReserved3)
|
||||
KeyMax Key = KeySuper
|
||||
KeyA Key = Key(driver.KeyA)
|
||||
KeyB Key = Key(driver.KeyB)
|
||||
KeyC Key = Key(driver.KeyC)
|
||||
KeyD Key = Key(driver.KeyD)
|
||||
KeyE Key = Key(driver.KeyE)
|
||||
KeyF Key = Key(driver.KeyF)
|
||||
KeyG Key = Key(driver.KeyG)
|
||||
KeyH Key = Key(driver.KeyH)
|
||||
KeyI Key = Key(driver.KeyI)
|
||||
KeyJ Key = Key(driver.KeyJ)
|
||||
KeyK Key = Key(driver.KeyK)
|
||||
KeyL Key = Key(driver.KeyL)
|
||||
KeyM Key = Key(driver.KeyM)
|
||||
KeyN Key = Key(driver.KeyN)
|
||||
KeyO Key = Key(driver.KeyO)
|
||||
KeyP Key = Key(driver.KeyP)
|
||||
KeyQ Key = Key(driver.KeyQ)
|
||||
KeyR Key = Key(driver.KeyR)
|
||||
KeyS Key = Key(driver.KeyS)
|
||||
KeyT Key = Key(driver.KeyT)
|
||||
KeyU Key = Key(driver.KeyU)
|
||||
KeyV Key = Key(driver.KeyV)
|
||||
KeyW Key = Key(driver.KeyW)
|
||||
KeyX Key = Key(driver.KeyX)
|
||||
KeyY Key = Key(driver.KeyY)
|
||||
KeyZ Key = Key(driver.KeyZ)
|
||||
KeyAltLeft Key = Key(driver.KeyAltLeft)
|
||||
KeyAltRight Key = Key(driver.KeyAltRight)
|
||||
KeyArrowDown Key = Key(driver.KeyArrowDown)
|
||||
KeyArrowLeft Key = Key(driver.KeyArrowLeft)
|
||||
KeyArrowRight Key = Key(driver.KeyArrowRight)
|
||||
KeyArrowUp Key = Key(driver.KeyArrowUp)
|
||||
KeyBackquote Key = Key(driver.KeyBackquote)
|
||||
KeyBackslash Key = Key(driver.KeyBackslash)
|
||||
KeyBackspace Key = Key(driver.KeyBackspace)
|
||||
KeyBracketLeft Key = Key(driver.KeyBracketLeft)
|
||||
KeyBracketRight Key = Key(driver.KeyBracketRight)
|
||||
KeyCapsLock Key = Key(driver.KeyCapsLock)
|
||||
KeyComma Key = Key(driver.KeyComma)
|
||||
KeyContextMenu Key = Key(driver.KeyContextMenu)
|
||||
KeyControlLeft Key = Key(driver.KeyControlLeft)
|
||||
KeyControlRight Key = Key(driver.KeyControlRight)
|
||||
KeyDelete Key = Key(driver.KeyDelete)
|
||||
KeyDigit0 Key = Key(driver.KeyDigit0)
|
||||
KeyDigit1 Key = Key(driver.KeyDigit1)
|
||||
KeyDigit2 Key = Key(driver.KeyDigit2)
|
||||
KeyDigit3 Key = Key(driver.KeyDigit3)
|
||||
KeyDigit4 Key = Key(driver.KeyDigit4)
|
||||
KeyDigit5 Key = Key(driver.KeyDigit5)
|
||||
KeyDigit6 Key = Key(driver.KeyDigit6)
|
||||
KeyDigit7 Key = Key(driver.KeyDigit7)
|
||||
KeyDigit8 Key = Key(driver.KeyDigit8)
|
||||
KeyDigit9 Key = Key(driver.KeyDigit9)
|
||||
KeyEnd Key = Key(driver.KeyEnd)
|
||||
KeyEnter Key = Key(driver.KeyEnter)
|
||||
KeyEqual Key = Key(driver.KeyEqual)
|
||||
KeyEscape Key = Key(driver.KeyEscape)
|
||||
KeyF1 Key = Key(driver.KeyF1)
|
||||
KeyF2 Key = Key(driver.KeyF2)
|
||||
KeyF3 Key = Key(driver.KeyF3)
|
||||
KeyF4 Key = Key(driver.KeyF4)
|
||||
KeyF5 Key = Key(driver.KeyF5)
|
||||
KeyF6 Key = Key(driver.KeyF6)
|
||||
KeyF7 Key = Key(driver.KeyF7)
|
||||
KeyF8 Key = Key(driver.KeyF8)
|
||||
KeyF9 Key = Key(driver.KeyF9)
|
||||
KeyF10 Key = Key(driver.KeyF10)
|
||||
KeyF11 Key = Key(driver.KeyF11)
|
||||
KeyF12 Key = Key(driver.KeyF12)
|
||||
KeyHome Key = Key(driver.KeyHome)
|
||||
KeyInsert Key = Key(driver.KeyInsert)
|
||||
KeyMetaLeft Key = Key(driver.KeyMetaLeft)
|
||||
KeyMetaRight Key = Key(driver.KeyMetaRight)
|
||||
KeyMinus Key = Key(driver.KeyMinus)
|
||||
KeyNumLock Key = Key(driver.KeyNumLock)
|
||||
KeyNumpad0 Key = Key(driver.KeyNumpad0)
|
||||
KeyNumpad1 Key = Key(driver.KeyNumpad1)
|
||||
KeyNumpad2 Key = Key(driver.KeyNumpad2)
|
||||
KeyNumpad3 Key = Key(driver.KeyNumpad3)
|
||||
KeyNumpad4 Key = Key(driver.KeyNumpad4)
|
||||
KeyNumpad5 Key = Key(driver.KeyNumpad5)
|
||||
KeyNumpad6 Key = Key(driver.KeyNumpad6)
|
||||
KeyNumpad7 Key = Key(driver.KeyNumpad7)
|
||||
KeyNumpad8 Key = Key(driver.KeyNumpad8)
|
||||
KeyNumpad9 Key = Key(driver.KeyNumpad9)
|
||||
KeyNumpadAdd Key = Key(driver.KeyNumpadAdd)
|
||||
KeyNumpadDecimal Key = Key(driver.KeyNumpadDecimal)
|
||||
KeyNumpadDivide Key = Key(driver.KeyNumpadDivide)
|
||||
KeyNumpadEnter Key = Key(driver.KeyNumpadEnter)
|
||||
KeyNumpadEqual Key = Key(driver.KeyNumpadEqual)
|
||||
KeyNumpadMultiply Key = Key(driver.KeyNumpadMultiply)
|
||||
KeyNumpadSubtract Key = Key(driver.KeyNumpadSubtract)
|
||||
KeyPageDown Key = Key(driver.KeyPageDown)
|
||||
KeyPageUp Key = Key(driver.KeyPageUp)
|
||||
KeyPause Key = Key(driver.KeyPause)
|
||||
KeyPeriod Key = Key(driver.KeyPeriod)
|
||||
KeyPrintScreen Key = Key(driver.KeyPrintScreen)
|
||||
KeyQuote Key = Key(driver.KeyQuote)
|
||||
KeyScrollLock Key = Key(driver.KeyScrollLock)
|
||||
KeySemicolon Key = Key(driver.KeySemicolon)
|
||||
KeyShiftLeft Key = Key(driver.KeyShiftLeft)
|
||||
KeyShiftRight Key = Key(driver.KeyShiftRight)
|
||||
KeySlash Key = Key(driver.KeySlash)
|
||||
KeySpace Key = Key(driver.KeySpace)
|
||||
KeyTab Key = Key(driver.KeyTab)
|
||||
KeyAlt Key = Key(driver.KeyReserved0)
|
||||
KeyControl Key = Key(driver.KeyReserved1)
|
||||
KeyShift Key = Key(driver.KeyReserved2)
|
||||
KeyMeta Key = Key(driver.KeyReserved3)
|
||||
KeyMax Key = KeyMeta
|
||||
|
||||
// Keys for backward compatibility.
|
||||
// Deprecated: as of 2.1.0.
|
||||
Key0 Key = Key(driver.KeyDigit0)
|
||||
Key1 Key = Key(driver.KeyDigit1)
|
||||
Key2 Key = Key(driver.KeyDigit2)
|
||||
Key3 Key = Key(driver.KeyDigit3)
|
||||
Key4 Key = Key(driver.KeyDigit4)
|
||||
Key5 Key = Key(driver.KeyDigit5)
|
||||
Key6 Key = Key(driver.KeyDigit6)
|
||||
Key7 Key = Key(driver.KeyDigit7)
|
||||
Key8 Key = Key(driver.KeyDigit8)
|
||||
Key9 Key = Key(driver.KeyDigit9)
|
||||
KeyApostrophe Key = Key(driver.KeyQuote)
|
||||
KeyDown Key = Key(driver.KeyArrowDown)
|
||||
KeyGraveAccent Key = Key(driver.KeyBackquote)
|
||||
KeyKP0 Key = Key(driver.KeyNumpad0)
|
||||
KeyKP1 Key = Key(driver.KeyNumpad1)
|
||||
KeyKP2 Key = Key(driver.KeyNumpad2)
|
||||
KeyKP3 Key = Key(driver.KeyNumpad3)
|
||||
KeyKP4 Key = Key(driver.KeyNumpad4)
|
||||
KeyKP5 Key = Key(driver.KeyNumpad5)
|
||||
KeyKP6 Key = Key(driver.KeyNumpad6)
|
||||
KeyKP7 Key = Key(driver.KeyNumpad7)
|
||||
KeyKP8 Key = Key(driver.KeyNumpad8)
|
||||
KeyKP9 Key = Key(driver.KeyNumpad9)
|
||||
KeyKPDecimal Key = Key(driver.KeyNumpadDecimal)
|
||||
KeyKPDivide Key = Key(driver.KeyNumpadDivide)
|
||||
KeyKPEnter Key = Key(driver.KeyNumpadEnter)
|
||||
KeyKPEqual Key = Key(driver.KeyNumpadEqual)
|
||||
KeyKPMultiply Key = Key(driver.KeyNumpadMultiply)
|
||||
KeyKPSubtract Key = Key(driver.KeyNumpadSubtract)
|
||||
KeyLeft Key = Key(driver.KeyArrowLeft)
|
||||
KeyLeftBracket Key = Key(driver.KeyBracketLeft)
|
||||
KeyMenu Key = Key(driver.KeyContextMenu)
|
||||
KeyRight Key = Key(driver.KeyArrowRight)
|
||||
KeyRightBracket Key = Key(driver.KeyBracketRight)
|
||||
KeyUp Key = Key(driver.KeyArrowUp)
|
||||
)
|
||||
|
||||
func (k Key) isValid() bool {
|
||||
switch k {
|
||||
case Key0:
|
||||
return true
|
||||
case Key1:
|
||||
return true
|
||||
case Key2:
|
||||
return true
|
||||
case Key3:
|
||||
return true
|
||||
case Key4:
|
||||
return true
|
||||
case Key5:
|
||||
return true
|
||||
case Key6:
|
||||
return true
|
||||
case Key7:
|
||||
return true
|
||||
case Key8:
|
||||
return true
|
||||
case Key9:
|
||||
return true
|
||||
case KeyA:
|
||||
return true
|
||||
case KeyB:
|
||||
@ -217,21 +235,61 @@ func (k Key) isValid() bool {
|
||||
return true
|
||||
case KeyAlt:
|
||||
return true
|
||||
case KeyApostrophe:
|
||||
case KeyAltLeft:
|
||||
return true
|
||||
case KeyAltRight:
|
||||
return true
|
||||
case KeyArrowDown:
|
||||
return true
|
||||
case KeyArrowLeft:
|
||||
return true
|
||||
case KeyArrowRight:
|
||||
return true
|
||||
case KeyArrowUp:
|
||||
return true
|
||||
case KeyBackquote:
|
||||
return true
|
||||
case KeyBackslash:
|
||||
return true
|
||||
case KeyBackspace:
|
||||
return true
|
||||
case KeyBracketLeft:
|
||||
return true
|
||||
case KeyBracketRight:
|
||||
return true
|
||||
case KeyCapsLock:
|
||||
return true
|
||||
case KeyComma:
|
||||
return true
|
||||
case KeyContextMenu:
|
||||
return true
|
||||
case KeyControl:
|
||||
return true
|
||||
case KeyControlLeft:
|
||||
return true
|
||||
case KeyControlRight:
|
||||
return true
|
||||
case KeyDelete:
|
||||
return true
|
||||
case KeyDown:
|
||||
case KeyDigit0:
|
||||
return true
|
||||
case KeyDigit1:
|
||||
return true
|
||||
case KeyDigit2:
|
||||
return true
|
||||
case KeyDigit3:
|
||||
return true
|
||||
case KeyDigit4:
|
||||
return true
|
||||
case KeyDigit5:
|
||||
return true
|
||||
case KeyDigit6:
|
||||
return true
|
||||
case KeyDigit7:
|
||||
return true
|
||||
case KeyDigit8:
|
||||
return true
|
||||
case KeyDigit9:
|
||||
return true
|
||||
case KeyEnd:
|
||||
return true
|
||||
@ -265,64 +323,54 @@ func (k Key) isValid() bool {
|
||||
return true
|
||||
case KeyF12:
|
||||
return true
|
||||
case KeyGraveAccent:
|
||||
return true
|
||||
case KeyHome:
|
||||
return true
|
||||
case KeyInsert:
|
||||
return true
|
||||
case KeyKP0:
|
||||
case KeyMeta:
|
||||
return true
|
||||
case KeyKP1:
|
||||
case KeyMetaLeft:
|
||||
return true
|
||||
case KeyKP2:
|
||||
return true
|
||||
case KeyKP3:
|
||||
return true
|
||||
case KeyKP4:
|
||||
return true
|
||||
case KeyKP5:
|
||||
return true
|
||||
case KeyKP6:
|
||||
return true
|
||||
case KeyKP7:
|
||||
return true
|
||||
case KeyKP8:
|
||||
return true
|
||||
case KeyKP9:
|
||||
return true
|
||||
case KeyKPAdd:
|
||||
return true
|
||||
case KeyKPDecimal:
|
||||
return true
|
||||
case KeyKPDivide:
|
||||
return true
|
||||
case KeyKPEnter:
|
||||
return true
|
||||
case KeyKPEqual:
|
||||
return true
|
||||
case KeyKPMultiply:
|
||||
return true
|
||||
case KeyKPSubtract:
|
||||
return true
|
||||
case KeyLeft:
|
||||
return true
|
||||
case KeyLeftAlt:
|
||||
return true
|
||||
case KeyLeftBracket:
|
||||
return true
|
||||
case KeyLeftControl:
|
||||
return true
|
||||
case KeyLeftShift:
|
||||
return true
|
||||
case KeyLeftSuper:
|
||||
return true
|
||||
case KeyMenu:
|
||||
case KeyMetaRight:
|
||||
return true
|
||||
case KeyMinus:
|
||||
return true
|
||||
case KeyNumLock:
|
||||
return true
|
||||
case KeyNumpad0:
|
||||
return true
|
||||
case KeyNumpad1:
|
||||
return true
|
||||
case KeyNumpad2:
|
||||
return true
|
||||
case KeyNumpad3:
|
||||
return true
|
||||
case KeyNumpad4:
|
||||
return true
|
||||
case KeyNumpad5:
|
||||
return true
|
||||
case KeyNumpad6:
|
||||
return true
|
||||
case KeyNumpad7:
|
||||
return true
|
||||
case KeyNumpad8:
|
||||
return true
|
||||
case KeyNumpad9:
|
||||
return true
|
||||
case KeyNumpadAdd:
|
||||
return true
|
||||
case KeyNumpadDecimal:
|
||||
return true
|
||||
case KeyNumpadDivide:
|
||||
return true
|
||||
case KeyNumpadEnter:
|
||||
return true
|
||||
case KeyNumpadEqual:
|
||||
return true
|
||||
case KeyNumpadMultiply:
|
||||
return true
|
||||
case KeyNumpadSubtract:
|
||||
return true
|
||||
case KeyPageDown:
|
||||
return true
|
||||
case KeyPageUp:
|
||||
@ -333,17 +381,7 @@ func (k Key) isValid() bool {
|
||||
return true
|
||||
case KeyPrintScreen:
|
||||
return true
|
||||
case KeyRight:
|
||||
return true
|
||||
case KeyRightAlt:
|
||||
return true
|
||||
case KeyRightBracket:
|
||||
return true
|
||||
case KeyRightControl:
|
||||
return true
|
||||
case KeyRightShift:
|
||||
return true
|
||||
case KeyRightSuper:
|
||||
case KeyQuote:
|
||||
return true
|
||||
case KeyScrollLock:
|
||||
return true
|
||||
@ -351,16 +389,16 @@ func (k Key) isValid() bool {
|
||||
return true
|
||||
case KeyShift:
|
||||
return true
|
||||
case KeyShiftLeft:
|
||||
return true
|
||||
case KeyShiftRight:
|
||||
return true
|
||||
case KeySlash:
|
||||
return true
|
||||
case KeySpace:
|
||||
return true
|
||||
case KeySuper:
|
||||
return true
|
||||
case KeyTab:
|
||||
return true
|
||||
case KeyUp:
|
||||
return true
|
||||
|
||||
default:
|
||||
return false
|
||||
@ -372,26 +410,6 @@ func (k Key) isValid() bool {
|
||||
// If k is an undefined key, String returns an empty string.
|
||||
func (k Key) String() string {
|
||||
switch k {
|
||||
case Key0:
|
||||
return "0"
|
||||
case Key1:
|
||||
return "1"
|
||||
case Key2:
|
||||
return "2"
|
||||
case Key3:
|
||||
return "3"
|
||||
case Key4:
|
||||
return "4"
|
||||
case Key5:
|
||||
return "5"
|
||||
case Key6:
|
||||
return "6"
|
||||
case Key7:
|
||||
return "7"
|
||||
case Key8:
|
||||
return "8"
|
||||
case Key9:
|
||||
return "9"
|
||||
case KeyA:
|
||||
return "A"
|
||||
case KeyB:
|
||||
@ -446,22 +464,62 @@ func (k Key) String() string {
|
||||
return "Z"
|
||||
case KeyAlt:
|
||||
return "Alt"
|
||||
case KeyApostrophe:
|
||||
return "Apostrophe"
|
||||
case KeyAltLeft:
|
||||
return "AltLeft"
|
||||
case KeyAltRight:
|
||||
return "AltRight"
|
||||
case KeyArrowDown:
|
||||
return "ArrowDown"
|
||||
case KeyArrowLeft:
|
||||
return "ArrowLeft"
|
||||
case KeyArrowRight:
|
||||
return "ArrowRight"
|
||||
case KeyArrowUp:
|
||||
return "ArrowUp"
|
||||
case KeyBackquote:
|
||||
return "Backquote"
|
||||
case KeyBackslash:
|
||||
return "Backslash"
|
||||
case KeyBackspace:
|
||||
return "Backspace"
|
||||
case KeyBracketLeft:
|
||||
return "BracketLeft"
|
||||
case KeyBracketRight:
|
||||
return "BracketRight"
|
||||
case KeyCapsLock:
|
||||
return "CapsLock"
|
||||
case KeyComma:
|
||||
return "Comma"
|
||||
case KeyContextMenu:
|
||||
return "ContextMenu"
|
||||
case KeyControl:
|
||||
return "Control"
|
||||
case KeyControlLeft:
|
||||
return "ControlLeft"
|
||||
case KeyControlRight:
|
||||
return "ControlRight"
|
||||
case KeyDelete:
|
||||
return "Delete"
|
||||
case KeyDown:
|
||||
return "Down"
|
||||
case KeyDigit0:
|
||||
return "Digit0"
|
||||
case KeyDigit1:
|
||||
return "Digit1"
|
||||
case KeyDigit2:
|
||||
return "Digit2"
|
||||
case KeyDigit3:
|
||||
return "Digit3"
|
||||
case KeyDigit4:
|
||||
return "Digit4"
|
||||
case KeyDigit5:
|
||||
return "Digit5"
|
||||
case KeyDigit6:
|
||||
return "Digit6"
|
||||
case KeyDigit7:
|
||||
return "Digit7"
|
||||
case KeyDigit8:
|
||||
return "Digit8"
|
||||
case KeyDigit9:
|
||||
return "Digit9"
|
||||
case KeyEnd:
|
||||
return "End"
|
||||
case KeyEnter:
|
||||
@ -494,64 +552,54 @@ func (k Key) String() string {
|
||||
return "F11"
|
||||
case KeyF12:
|
||||
return "F12"
|
||||
case KeyGraveAccent:
|
||||
return "GraveAccent"
|
||||
case KeyHome:
|
||||
return "Home"
|
||||
case KeyInsert:
|
||||
return "Insert"
|
||||
case KeyKP0:
|
||||
return "KP0"
|
||||
case KeyKP1:
|
||||
return "KP1"
|
||||
case KeyKP2:
|
||||
return "KP2"
|
||||
case KeyKP3:
|
||||
return "KP3"
|
||||
case KeyKP4:
|
||||
return "KP4"
|
||||
case KeyKP5:
|
||||
return "KP5"
|
||||
case KeyKP6:
|
||||
return "KP6"
|
||||
case KeyKP7:
|
||||
return "KP7"
|
||||
case KeyKP8:
|
||||
return "KP8"
|
||||
case KeyKP9:
|
||||
return "KP9"
|
||||
case KeyKPAdd:
|
||||
return "KPAdd"
|
||||
case KeyKPDecimal:
|
||||
return "KPDecimal"
|
||||
case KeyKPDivide:
|
||||
return "KPDivide"
|
||||
case KeyKPEnter:
|
||||
return "KPEnter"
|
||||
case KeyKPEqual:
|
||||
return "KPEqual"
|
||||
case KeyKPMultiply:
|
||||
return "KPMultiply"
|
||||
case KeyKPSubtract:
|
||||
return "KPSubtract"
|
||||
case KeyLeft:
|
||||
return "Left"
|
||||
case KeyLeftAlt:
|
||||
return "LeftAlt"
|
||||
case KeyLeftBracket:
|
||||
return "LeftBracket"
|
||||
case KeyLeftControl:
|
||||
return "LeftControl"
|
||||
case KeyLeftShift:
|
||||
return "LeftShift"
|
||||
case KeyLeftSuper:
|
||||
return "LeftSuper"
|
||||
case KeyMenu:
|
||||
return "Menu"
|
||||
case KeyMeta:
|
||||
return "Meta"
|
||||
case KeyMetaLeft:
|
||||
return "MetaLeft"
|
||||
case KeyMetaRight:
|
||||
return "MetaRight"
|
||||
case KeyMinus:
|
||||
return "Minus"
|
||||
case KeyNumLock:
|
||||
return "NumLock"
|
||||
case KeyNumpad0:
|
||||
return "Numpad0"
|
||||
case KeyNumpad1:
|
||||
return "Numpad1"
|
||||
case KeyNumpad2:
|
||||
return "Numpad2"
|
||||
case KeyNumpad3:
|
||||
return "Numpad3"
|
||||
case KeyNumpad4:
|
||||
return "Numpad4"
|
||||
case KeyNumpad5:
|
||||
return "Numpad5"
|
||||
case KeyNumpad6:
|
||||
return "Numpad6"
|
||||
case KeyNumpad7:
|
||||
return "Numpad7"
|
||||
case KeyNumpad8:
|
||||
return "Numpad8"
|
||||
case KeyNumpad9:
|
||||
return "Numpad9"
|
||||
case KeyNumpadAdd:
|
||||
return "NumpadAdd"
|
||||
case KeyNumpadDecimal:
|
||||
return "NumpadDecimal"
|
||||
case KeyNumpadDivide:
|
||||
return "NumpadDivide"
|
||||
case KeyNumpadEnter:
|
||||
return "NumpadEnter"
|
||||
case KeyNumpadEqual:
|
||||
return "NumpadEqual"
|
||||
case KeyNumpadMultiply:
|
||||
return "NumpadMultiply"
|
||||
case KeyNumpadSubtract:
|
||||
return "NumpadSubtract"
|
||||
case KeyPageDown:
|
||||
return "PageDown"
|
||||
case KeyPageUp:
|
||||
@ -562,34 +610,24 @@ func (k Key) String() string {
|
||||
return "Period"
|
||||
case KeyPrintScreen:
|
||||
return "PrintScreen"
|
||||
case KeyRight:
|
||||
return "Right"
|
||||
case KeyRightAlt:
|
||||
return "RightAlt"
|
||||
case KeyRightBracket:
|
||||
return "RightBracket"
|
||||
case KeyRightControl:
|
||||
return "RightControl"
|
||||
case KeyRightShift:
|
||||
return "RightShift"
|
||||
case KeyRightSuper:
|
||||
return "RightSuper"
|
||||
case KeyQuote:
|
||||
return "Quote"
|
||||
case KeyScrollLock:
|
||||
return "ScrollLock"
|
||||
case KeySemicolon:
|
||||
return "Semicolon"
|
||||
case KeyShift:
|
||||
return "Shift"
|
||||
case KeyShiftLeft:
|
||||
return "ShiftLeft"
|
||||
case KeyShiftRight:
|
||||
return "ShiftRight"
|
||||
case KeySlash:
|
||||
return "Slash"
|
||||
case KeySpace:
|
||||
return "Space"
|
||||
case KeySuper:
|
||||
return "Super"
|
||||
case KeyTab:
|
||||
return "Tab"
|
||||
case KeyUp:
|
||||
return "Up"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@ -670,20 +708,64 @@ func keyNameToKeyCode(name string) (Key, bool) {
|
||||
return KeyZ, true
|
||||
case "alt":
|
||||
return KeyAlt, true
|
||||
case "altleft":
|
||||
return KeyAltLeft, true
|
||||
case "altright":
|
||||
return KeyAltRight, true
|
||||
case "apostrophe":
|
||||
return KeyApostrophe, true
|
||||
case "arrowdown":
|
||||
return KeyArrowDown, true
|
||||
case "arrowleft":
|
||||
return KeyArrowLeft, true
|
||||
case "arrowright":
|
||||
return KeyArrowRight, true
|
||||
case "arrowup":
|
||||
return KeyArrowUp, true
|
||||
case "backquote":
|
||||
return KeyBackquote, true
|
||||
case "backslash":
|
||||
return KeyBackslash, true
|
||||
case "backspace":
|
||||
return KeyBackspace, true
|
||||
case "bracketleft":
|
||||
return KeyBracketLeft, true
|
||||
case "bracketright":
|
||||
return KeyBracketRight, true
|
||||
case "capslock":
|
||||
return KeyCapsLock, true
|
||||
case "comma":
|
||||
return KeyComma, true
|
||||
case "contextmenu":
|
||||
return KeyContextMenu, true
|
||||
case "control":
|
||||
return KeyControl, true
|
||||
case "controlleft":
|
||||
return KeyControlLeft, true
|
||||
case "controlright":
|
||||
return KeyControlRight, true
|
||||
case "delete":
|
||||
return KeyDelete, true
|
||||
case "digit0":
|
||||
return KeyDigit0, true
|
||||
case "digit1":
|
||||
return KeyDigit1, true
|
||||
case "digit2":
|
||||
return KeyDigit2, true
|
||||
case "digit3":
|
||||
return KeyDigit3, true
|
||||
case "digit4":
|
||||
return KeyDigit4, true
|
||||
case "digit5":
|
||||
return KeyDigit5, true
|
||||
case "digit6":
|
||||
return KeyDigit6, true
|
||||
case "digit7":
|
||||
return KeyDigit7, true
|
||||
case "digit8":
|
||||
return KeyDigit8, true
|
||||
case "digit9":
|
||||
return KeyDigit9, true
|
||||
case "down":
|
||||
return KeyDown, true
|
||||
case "end":
|
||||
@ -744,8 +826,6 @@ func keyNameToKeyCode(name string) (Key, bool) {
|
||||
return KeyKP8, true
|
||||
case "kp9":
|
||||
return KeyKP9, true
|
||||
case "kpadd":
|
||||
return KeyKPAdd, true
|
||||
case "kpdecimal":
|
||||
return KeyKPDecimal, true
|
||||
case "kpdivide":
|
||||
@ -760,22 +840,54 @@ func keyNameToKeyCode(name string) (Key, bool) {
|
||||
return KeyKPSubtract, true
|
||||
case "left":
|
||||
return KeyLeft, true
|
||||
case "leftalt":
|
||||
return KeyLeftAlt, true
|
||||
case "leftbracket":
|
||||
return KeyLeftBracket, true
|
||||
case "leftcontrol":
|
||||
return KeyLeftControl, true
|
||||
case "leftshift":
|
||||
return KeyLeftShift, true
|
||||
case "leftsuper":
|
||||
return KeyLeftSuper, true
|
||||
case "menu":
|
||||
return KeyMenu, true
|
||||
case "meta":
|
||||
return KeyMeta, true
|
||||
case "metaleft":
|
||||
return KeyMetaLeft, true
|
||||
case "metaright":
|
||||
return KeyMetaRight, true
|
||||
case "minus":
|
||||
return KeyMinus, true
|
||||
case "numlock":
|
||||
return KeyNumLock, true
|
||||
case "numpad0":
|
||||
return KeyNumpad0, true
|
||||
case "numpad1":
|
||||
return KeyNumpad1, true
|
||||
case "numpad2":
|
||||
return KeyNumpad2, true
|
||||
case "numpad3":
|
||||
return KeyNumpad3, true
|
||||
case "numpad4":
|
||||
return KeyNumpad4, true
|
||||
case "numpad5":
|
||||
return KeyNumpad5, true
|
||||
case "numpad6":
|
||||
return KeyNumpad6, true
|
||||
case "numpad7":
|
||||
return KeyNumpad7, true
|
||||
case "numpad8":
|
||||
return KeyNumpad8, true
|
||||
case "numpad9":
|
||||
return KeyNumpad9, true
|
||||
case "numpadadd":
|
||||
return KeyNumpadAdd, true
|
||||
case "numpaddecimal":
|
||||
return KeyNumpadDecimal, true
|
||||
case "numpaddivide":
|
||||
return KeyNumpadDivide, true
|
||||
case "numpadenter":
|
||||
return KeyNumpadEnter, true
|
||||
case "numpadequal":
|
||||
return KeyNumpadEqual, true
|
||||
case "numpadmultiply":
|
||||
return KeyNumpadMultiply, true
|
||||
case "numpadsubtract":
|
||||
return KeyNumpadSubtract, true
|
||||
case "pagedown":
|
||||
return KeyPageDown, true
|
||||
case "pageup":
|
||||
@ -786,30 +898,26 @@ func keyNameToKeyCode(name string) (Key, bool) {
|
||||
return KeyPeriod, true
|
||||
case "printscreen":
|
||||
return KeyPrintScreen, true
|
||||
case "quote":
|
||||
return KeyQuote, true
|
||||
case "right":
|
||||
return KeyRight, true
|
||||
case "rightalt":
|
||||
return KeyRightAlt, true
|
||||
case "rightbracket":
|
||||
return KeyRightBracket, true
|
||||
case "rightcontrol":
|
||||
return KeyRightControl, true
|
||||
case "rightshift":
|
||||
return KeyRightShift, true
|
||||
case "rightsuper":
|
||||
return KeyRightSuper, true
|
||||
case "scrolllock":
|
||||
return KeyScrollLock, true
|
||||
case "semicolon":
|
||||
return KeySemicolon, true
|
||||
case "shift":
|
||||
return KeyShift, true
|
||||
case "shiftleft":
|
||||
return KeyShiftLeft, true
|
||||
case "shiftright":
|
||||
return KeyShiftRight, true
|
||||
case "slash":
|
||||
return KeySlash, true
|
||||
case "space":
|
||||
return KeySpace, true
|
||||
case "super":
|
||||
return KeySuper, true
|
||||
case "tab":
|
||||
return KeyTab, true
|
||||
case "up":
|
||||
|
@ -21,20 +21,20 @@ import (
|
||||
)
|
||||
|
||||
var androidKeyToDriverKey = map[int]driver.Key{
|
||||
7: driver.Key0,
|
||||
8: driver.Key1,
|
||||
9: driver.Key2,
|
||||
10: driver.Key3,
|
||||
11: driver.Key4,
|
||||
12: driver.Key5,
|
||||
13: driver.Key6,
|
||||
14: driver.Key7,
|
||||
15: driver.Key8,
|
||||
16: driver.Key9,
|
||||
19: driver.KeyUp,
|
||||
20: driver.KeyDown,
|
||||
21: driver.KeyLeft,
|
||||
22: driver.KeyRight,
|
||||
7: driver.KeyDigit0,
|
||||
8: driver.KeyDigit1,
|
||||
9: driver.KeyDigit2,
|
||||
10: driver.KeyDigit3,
|
||||
11: driver.KeyDigit4,
|
||||
12: driver.KeyDigit5,
|
||||
13: driver.KeyDigit6,
|
||||
14: driver.KeyDigit7,
|
||||
15: driver.KeyDigit8,
|
||||
16: driver.KeyDigit9,
|
||||
19: driver.KeyArrowUp,
|
||||
20: driver.KeyArrowDown,
|
||||
21: driver.KeyArrowLeft,
|
||||
22: driver.KeyArrowRight,
|
||||
29: driver.KeyA,
|
||||
30: driver.KeyB,
|
||||
31: driver.KeyC,
|
||||
@ -63,34 +63,34 @@ var androidKeyToDriverKey = map[int]driver.Key{
|
||||
54: driver.KeyZ,
|
||||
55: driver.KeyComma,
|
||||
56: driver.KeyPeriod,
|
||||
57: driver.KeyLeftAlt,
|
||||
58: driver.KeyRightAlt,
|
||||
59: driver.KeyLeftShift,
|
||||
60: driver.KeyRightShift,
|
||||
57: driver.KeyAltLeft,
|
||||
58: driver.KeyAltRight,
|
||||
59: driver.KeyShiftLeft,
|
||||
60: driver.KeyShiftRight,
|
||||
61: driver.KeyTab,
|
||||
62: driver.KeySpace,
|
||||
66: driver.KeyEnter,
|
||||
67: driver.KeyBackspace,
|
||||
68: driver.KeyGraveAccent,
|
||||
68: driver.KeyBackquote,
|
||||
69: driver.KeyMinus,
|
||||
70: driver.KeyEqual,
|
||||
71: driver.KeyLeftBracket,
|
||||
72: driver.KeyRightBracket,
|
||||
71: driver.KeyBracketLeft,
|
||||
72: driver.KeyBracketRight,
|
||||
73: driver.KeyBackslash,
|
||||
74: driver.KeySemicolon,
|
||||
75: driver.KeyApostrophe,
|
||||
75: driver.KeyQuote,
|
||||
76: driver.KeySlash,
|
||||
82: driver.KeyMenu,
|
||||
82: driver.KeyContextMenu,
|
||||
92: driver.KeyPageUp,
|
||||
93: driver.KeyPageDown,
|
||||
111: driver.KeyEscape,
|
||||
112: driver.KeyDelete,
|
||||
113: driver.KeyLeftControl,
|
||||
114: driver.KeyRightControl,
|
||||
113: driver.KeyControlLeft,
|
||||
114: driver.KeyControlRight,
|
||||
115: driver.KeyCapsLock,
|
||||
116: driver.KeyScrollLock,
|
||||
117: driver.KeyLeftSuper,
|
||||
118: driver.KeyRightSuper,
|
||||
117: driver.KeyMetaLeft,
|
||||
118: driver.KeyMetaRight,
|
||||
120: driver.KeyPrintScreen,
|
||||
121: driver.KeyPause,
|
||||
122: driver.KeyHome,
|
||||
@ -109,21 +109,21 @@ var androidKeyToDriverKey = map[int]driver.Key{
|
||||
141: driver.KeyF11,
|
||||
142: driver.KeyF12,
|
||||
143: driver.KeyNumLock,
|
||||
144: driver.KeyKP0,
|
||||
145: driver.KeyKP1,
|
||||
146: driver.KeyKP2,
|
||||
147: driver.KeyKP3,
|
||||
148: driver.KeyKP4,
|
||||
149: driver.KeyKP5,
|
||||
150: driver.KeyKP6,
|
||||
151: driver.KeyKP7,
|
||||
152: driver.KeyKP8,
|
||||
153: driver.KeyKP9,
|
||||
154: driver.KeyKPDivide,
|
||||
155: driver.KeyKPMultiply,
|
||||
156: driver.KeyKPSubtract,
|
||||
157: driver.KeyKPAdd,
|
||||
158: driver.KeyKPDecimal,
|
||||
160: driver.KeyKPEnter,
|
||||
161: driver.KeyKPEqual,
|
||||
144: driver.KeyNumpad0,
|
||||
145: driver.KeyNumpad1,
|
||||
146: driver.KeyNumpad2,
|
||||
147: driver.KeyNumpad3,
|
||||
148: driver.KeyNumpad4,
|
||||
149: driver.KeyNumpad5,
|
||||
150: driver.KeyNumpad6,
|
||||
151: driver.KeyNumpad7,
|
||||
152: driver.KeyNumpad8,
|
||||
153: driver.KeyNumpad9,
|
||||
154: driver.KeyNumpadDivide,
|
||||
155: driver.KeyNumpadMultiply,
|
||||
156: driver.KeyNumpadSubtract,
|
||||
157: driver.KeyNumpadAdd,
|
||||
158: driver.KeyNumpadDecimal,
|
||||
160: driver.KeyNumpadEnter,
|
||||
161: driver.KeyNumpadEqual,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user