ebiten/input/keyboard.go

31 lines
452 B
Go
Raw Normal View History

2014-12-07 14:10:04 +01:00
package input
2014-12-06 19:27:55 +01:00
type Key int
2014-12-08 14:51:40 +01:00
// TODO: Add more keys.
2014-12-06 19:27:55 +01:00
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 {
2014-12-08 14:51:40 +01:00
panic("input.IsKeyPressed: currentKeyboard is not set")
2014-12-06 19:27:55 +01:00
}
return currentKeyboard.IsKeyPressed(key)
}