ebiten/input/keyboard.go
2014-12-08 22:51:40 +09:00

31 lines
452 B
Go

package input
type Key int
// TODO: Add more keys.
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("input.IsKeyPressed: currentKeyboard is not set")
}
return currentKeyboard.IsKeyPressed(key)
}