mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
parent
f789c285ad
commit
0c0cd7e9d6
@ -244,14 +244,26 @@ func initialize() error {
|
|||||||
|
|
||||||
// Keyboard
|
// Keyboard
|
||||||
canvas.Call("addEventListener", "keydown", func(e *js.Object) {
|
canvas.Call("addEventListener", "keydown", func(e *js.Object) {
|
||||||
if e.Get("code") == js.Undefined {
|
c := e.Get("code")
|
||||||
// Assume that UA is Safari.
|
if c == js.Undefined {
|
||||||
|
// TODO: Now this is used for Edge, not Safari. Rename functions.
|
||||||
code := e.Get("keyCode").Int()
|
code := e.Get("keyCode").Int()
|
||||||
currentInput.keyDownSafari(code)
|
if keyCodeToKeySafari[code] == KeyUp ||
|
||||||
|
keyCodeToKeySafari[code] == KeyDown ||
|
||||||
|
keyCodeToKeySafari[code] == KeyLeft ||
|
||||||
|
keyCodeToKeySafari[code] == KeyRight {
|
||||||
|
currentInput.keyDownSafari(code)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
code := e.Get("code").String()
|
cs := c.String()
|
||||||
currentInput.keyDown(code)
|
if cs == keyToCodes[KeyUp][0] ||
|
||||||
|
cs == keyToCodes[KeyDown][0] ||
|
||||||
|
cs == keyToCodes[KeyLeft][0] ||
|
||||||
|
cs == keyToCodes[KeyRight][0] {
|
||||||
|
e.Call("preventDefault")
|
||||||
|
}
|
||||||
|
currentInput.keyDown(cs)
|
||||||
})
|
})
|
||||||
canvas.Call("addEventListener", "keypress", func(e *js.Object) {
|
canvas.Call("addEventListener", "keypress", func(e *js.Object) {
|
||||||
e.Call("preventDefault")
|
e.Call("preventDefault")
|
||||||
|
Loading…
Reference in New Issue
Block a user