Add function keys to example/keyboard

This commit is contained in:
Hajime Hoshi 2015-01-07 23:08:06 +09:00
parent 6bdc875596
commit 90ab31a872

View File

@ -19,6 +19,7 @@ import (
"github.com/hajimehoshi/ebiten/ebitenutil" "github.com/hajimehoshi/ebiten/ebitenutil"
"log" "log"
"sort" "sort"
"strconv"
"strings" "strings"
) )
@ -63,6 +64,11 @@ func update(screen *ebiten.Image) error {
pressed = append(pressed, string(c)) pressed = append(pressed, string(c))
} }
} }
for i := 1; i <= 12; i++ {
if ebiten.IsKeyPressed(ebiten.Key(i) + ebiten.KeyF1 - 1) {
pressed = append(pressed, "F"+strconv.Itoa(i))
}
}
for key, name := range keyNames { for key, name := range keyNames {
if ebiten.IsKeyPressed(key) { if ebiten.IsKeyPressed(key) {
pressed = append(pressed, name) pressed = append(pressed, name)