mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2026-04-23 00:07:15 +08:00
+11
-4
@@ -166,14 +166,14 @@ func (i *inputState) update() {
|
||||
}
|
||||
}
|
||||
|
||||
// PressedKeys returns a set of currently pressed keyboard keys.
|
||||
// AppendPressedKeys append currently pressed keyboard keys to keys and returns the extended buffer.
|
||||
// Giving a slice that already has enough capacity works efficiently.
|
||||
//
|
||||
// PressedKeys is concurrent safe.
|
||||
func PressedKeys() []ebiten.Key {
|
||||
// AppendPressedKeys is concurrent safe.
|
||||
func AppendPressedKeys(keys []ebiten.Key) []ebiten.Key {
|
||||
theInputState.m.RLock()
|
||||
defer theInputState.m.RUnlock()
|
||||
|
||||
keys := make([]ebiten.Key, 0, len(theInputState.keyDurations))
|
||||
for i, d := range theInputState.keyDurations {
|
||||
if d == 0 {
|
||||
continue
|
||||
@@ -183,6 +183,13 @@ func PressedKeys() []ebiten.Key {
|
||||
return keys
|
||||
}
|
||||
|
||||
// PressedKeys returns a set of currently pressed keyboard keys.
|
||||
//
|
||||
// Deprecated: as of v2.2.0. Use AppendPressedKeys instead.
|
||||
func PressedKeys() []ebiten.Key {
|
||||
return AppendPressedKeys(nil)
|
||||
}
|
||||
|
||||
// IsKeyJustPressed returns a boolean value indicating
|
||||
// whether the given key is pressed just in the current frame.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user