Here is the list of features:
- Provides the key_up, key_down, and key_repeat procs for all objects which are passed the key and client when a keyboard event occurs.
- Provides the client.focus var, which is a reference to an object that will receive keyboard events. When a key press, release, or repeat event occurs, client.focus.key_up/down/repeat will be called. By default client.focus is the client itself.
- Provides a default implementation of the client's key_down and key_repeat procs which call the client's North, South, Center, etc. procs.
- Provides the client.keys var which is an associative list which stores the state of each key - client.keys["a"] is 1 if the A key is being held and 0 if it's not held.
- Provides the client.lock_input, unlock_input, and clear_input procs. The first two are used to lock/unlock input - while input is locked the key_up/down/repeat procs will not be called (but the keys list will still be updated to reflect key releases only). The clear_input proc clears the keys list (sets all values to zero).
- Provides five demos:
- focus-demo: Shows the effect of changing client.focus.
- icon-selection-demo: Shows how to use client.focus to create an icon selection feature that uses keyboard events to change your icon.
- mob-demo: Shows how to control other mobs by changing client.focus.
- movement-demo: Shows how to create a different movement system by using the client.keys list.
- simple-demo: Shows how to use the mob's key_down proc to cause actions to occur when certain keys are pressed.
The library includes five demos that show different ways it can be used. Sometimes when I post a library I deliberately don't implement all of the features I have in mind. I leave a couple of features for later updates so that I have updates to make. That wasn't the case here - I'm clean out of ideas for this one. If there are any features or demos you'd like to see added to this library, your suggestions would be very much appreciated.