internal/ui: fix a potential out-of-range error

This commit is contained in:
Hajime Hoshi 2023-01-24 00:32:08 +09:00
parent 7f39b9c5b6
commit 16e49e0499

View File

@ -51,11 +51,19 @@ var codeToMouseButton = map[int]MouseButton{
}
func (u *userInterfaceImpl) keyDown(code js.Value) {
u.inputState.KeyPressed[jsKeyToID(code)] = true
id := jsKeyToID(code)
if id < 0 {
return
}
u.inputState.KeyPressed[id] = true
}
func (u *userInterfaceImpl) keyUp(code js.Value) {
u.inputState.KeyPressed[jsKeyToID(code)] = false
id := jsKeyToID(code)
if id < 0 {
return
}
u.inputState.KeyPressed[id] = false
}
func (u *userInterfaceImpl) mouseDown(code int) {