ebiten/input/keyboard.go
Hajime Hoshi 7fd54f6bb3 Add input
2014-12-07 22:10:04 +09:00

30 lines
425 B
Go

package input
type Key int
const (
KeyUp Key = iota
KeyDown
KeyLeft
KeyRight
KeySpace
KeyMax
)
var currentKeyboard Keyboard
type Keyboard interface {
IsKeyPressed(key Key) bool
}
func SetKeyboard(keyboard Keyboard) {
currentKeyboard = keyboard
}
func IsKeyPressed(key Key) bool {
if currentKeyboard == nil {
panic("ui.IsKeyPressed: currentKeyboard is not set")
}
return currentKeyboard.IsKeyPressed(key)
}