diff --git a/genkeys.go b/genkeys.go index 7ef53f674..abac2c8f9 100644 --- a/genkeys.go +++ b/genkeys.go @@ -129,6 +129,16 @@ func init() { 0xdd: "RightBracket", 0xc0: "GraveAccent", 0x08: "Backspace", + 0x90: "NumLock", + 0x6e: "KPDecimal", + 0x6f: "KPDivide", + 0x6a: "KPMultiply", + 0x6d: "KPSubtract", + 0x6b: "KPAdd", + + // TODO: On Edge, it is impossible to tell KPEnter and Enter / KPEqual and Equal. + // 0x0d: "KPEnter", + // 0x0c: "KPEqual", } // ASCII: 0 - 9 for c := '0'; c <= '9'; c++ { @@ -142,7 +152,10 @@ func init() { for i := 1; i <= 12; i++ { keyCodeToNameEdge[0x70+i-1] = "F" + strconv.Itoa(i) } - // TODO: Add numpad keys + // Numpad keys + for c := '0'; c <= '9'; c++ { + keyCodeToNameEdge[0x60+int(c-'0')] = "KP" + string(c) + } } const ebitenKeysTmpl = `{{.License}} @@ -162,7 +175,9 @@ import ( // For example, KeyQ represents Q key on US keyboards and ' (quote) key on Dvorak keyboards. type Key int -// Keys +// Keys. +// +// Known issue: KeyKPEnter and KeyKPEqual don't work on Edge browsers. const ( {{range $index, $name := .KeyNames}}Key{{$name}} Key = Key(input.Key{{$name}}) {{end}} KeyMax Key = Key{{.LastKeyName}} diff --git a/internal/input/keys_js.go b/internal/input/keys_js.go index 9a2ad12e7..85599a27c 100644 --- a/internal/input/keys_js.go +++ b/internal/input/keys_js.go @@ -365,6 +365,21 @@ var keyCodeToKeyEdge = map[int]Key{ 88: KeyX, 89: KeyY, 90: KeyZ, + 96: KeyKP0, + 97: KeyKP1, + 98: KeyKP2, + 99: KeyKP3, + 100: KeyKP4, + 101: KeyKP5, + 102: KeyKP6, + 103: KeyKP7, + 104: KeyKP8, + 105: KeyKP9, + 106: KeyKPMultiply, + 107: KeyKPAdd, + 109: KeyKPSubtract, + 110: KeyKPDecimal, + 111: KeyKPDivide, 112: KeyF1, 113: KeyF2, 114: KeyF3, @@ -377,6 +392,7 @@ var keyCodeToKeyEdge = map[int]Key{ 121: KeyF10, 122: KeyF11, 123: KeyF12, + 144: KeyNumLock, 186: KeySemicolon, 187: KeyEqual, 188: KeyComma, diff --git a/keys.go b/keys.go index 8e9578c5d..b7266d264 100644 --- a/keys.go +++ b/keys.go @@ -27,7 +27,9 @@ import ( // For example, KeyQ represents Q key on US keyboards and ' (quote) key on Dvorak keyboards. type Key int -// Keys +// Keys. +// +// Known issue: KeyKPEnter and KeyKPEqual don't work on Edge browsers. const ( Key0 Key = Key(input.Key0) Key1 Key = Key(input.Key1)