Last active
July 30, 2021 12:05
-
-
Save andrew-wilkes/dd3d603539904e3bda3c267237c18aff to your computer and use it in GitHub Desktop.
GDScript Code to Ignore Key Repeats
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var keys = {} | |
| func _unhandled_input(event): | |
| if event is InputEventKey: | |
| # Add new key to dictionary | |
| if not keys.has(event.scancode): | |
| keys[event.scancode] = false | |
| # Respond to change in key state (pressed or released) | |
| if event.pressed != keys[event.scancode]: | |
| # Remember the current state | |
| keys[event.scancode] = event.pressed | |
| # Call your handler function | |
| handle_state(event.scancode, event.pressed) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment