Skip to content

Instantly share code, notes, and snippets.

@andrew-wilkes
Last active July 30, 2021 12:05
Show Gist options
  • Select an option

  • Save andrew-wilkes/dd3d603539904e3bda3c267237c18aff to your computer and use it in GitHub Desktop.

Select an option

Save andrew-wilkes/dd3d603539904e3bda3c267237c18aff to your computer and use it in GitHub Desktop.
GDScript Code to Ignore Key Repeats
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