Events for listening to keybinds
moonheart08 opened this issue ยท 3 comments
At the moment, there is no sane way to have an event fire upon pressing a key without using mixins to modify the input code.
I propose the addition of an event that allows a function to be called whenever a key is pressed or released, to help keep the input code clean of external mixins.
still hoping for this. Would even be nice to have a keybinding helper method doing effectively a non-clearing "wasPressed" to call handlers and then decrements the pressed count if the event consumes. seems the PR that was supposed to do this has been waiting for review for over a year now
I see two potential events here:
- Event fired whenever a registered
KeyBinding
changes state (e.g."key.jump"
), the key set in the options menu - Event fired whenever a key is pressed or released (e.g.
"key.keyboard.space"
), the actual key code
The first is more obviously useful to most mod developers (I can see "magical dances" or key loggers for screen recording being a thing for example).
The second could be abused to hardcode key-bindings, but can still be potentially useful for debugging, logging, scripting, or special items.