Skip to content

Commit

Permalink
input: Add numpad keys for Edge (#580)
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi committed Apr 13, 2018
1 parent dd6110f commit 61d4df0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
19 changes: 17 additions & 2 deletions genkeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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++ {
Expand All @@ -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}}
Expand All @@ -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}}
Expand Down
16 changes: 16 additions & 0 deletions internal/input/keys_js.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion keys.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 61d4df0

Please sign in to comment.