diff --git a/examples/keyboard/main.go b/examples/keyboard/main.go index 9a4469cb4..db1d043e4 100644 --- a/examples/keyboard/main.go +++ b/examples/keyboard/main.go @@ -21,8 +21,10 @@ import ( "image" _ "image/png" "log" + "strings" "github.com/hajimehoshi/ebiten" + "github.com/hajimehoshi/ebiten/ebitenutil" "github.com/hajimehoshi/ebiten/examples/keyboard/keyboard" rkeyabord "github.com/hajimehoshi/ebiten/examples/resources/images/keyboard" ) @@ -44,7 +46,6 @@ func init() { } func update(screen *ebiten.Image) error { - // Collect pressed keys' names. pressed := []ebiten.Key{} for k := ebiten.Key(0); k <= ebiten.KeyMax; k++ { if ebiten.IsKeyPressed(k) { @@ -81,6 +82,12 @@ func update(screen *ebiten.Image) error { screen.DrawImage(keyboardImage, op) } + keyStrs := []string{} + for _, p := range pressed { + keyStrs = append(keyStrs, p.String()) + } + ebitenutil.DebugPrint(screen, strings.Join(keyStrs, ", ")) + return nil } diff --git a/input.go b/input.go index 0ff5b0711..e72b4a432 100644 --- a/input.go +++ b/input.go @@ -35,6 +35,9 @@ func InputChars() []rune { // IsKeyPressed returns a boolean indicating whether key is pressed. // +// Known issue: On Edge browser, KeyKPEnter and KeyKPEqual don't work well. +// These keys are recognized as KeyEnter and KeyEqual. +// // This function is concurrent-safe. func IsKeyPressed(key Key) bool { return input.Get().IsKeyPressed(input.Key(key)) diff --git a/keys.go b/keys.go index aef42eceb..703bf9e0e 100644 --- a/keys.go +++ b/keys.go @@ -28,8 +28,6 @@ import ( type Key int // Keys. -// -// Known issue: KeyKPEnter and KeyKPEqual don't work on Edge browsers. const ( Key0 Key = Key(input.Key0) Key1 Key = Key(input.Key1)