input: Add numpad keys for Edge (#580)

This commit is contained in:
Hajime Hoshi 2018-04-14 02:29:18 +09:00
parent dd6110fbf8
commit 61d4df0e04
3 changed files with 36 additions and 3 deletions

View File

@ -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}}

View File

@ -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,

View File

@ -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)