mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-02-15 12:30:08 +01:00
30 lines
422 B
Go
30 lines
422 B
Go
|
package ui
|
||
|
|
||
|
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)
|
||
|
}
|