In your game, when you want to do an action like moving a character, you will be listening to the keyboard events, to know if the key to move forward, backward or to start a specific action is pressed or released. That's great, but as soon as you allow the user to customize the actions key, it becomes much more complicated.
With JPShortcut, you will be listening for action events instead of keys. JPShortcut will send you events to let you know when an action shortcut is pressed or released, whatever the shortcut is.
JPShortcut embeds functions to be called by your shortcut editor interface. Tell JPShortcut that the "Forward" action has been clicked by the user to be edited, and JPShortcut will automatically change the shortcut as soon as a new key is pressed, and will notify you of the new key to let you update the interface with the new action key name.
JPShortcut is compatible with mouse buttons as well as joypad buttons.
Here is a quick example, starting from the setup step:
Here's the code if you want to do something as long as the action shortcut is pressed:
And here the code for actions called once, in the onActionShortcutPressed (or Released) handler, automatically called by JPShortcut when the action is triggered:
In these 2 cases, even if the shortcut changes, your script remain the same as it is looking for actions state instead of keys or buttons states.