Keyboard
The Keyboard module was designed for easy use in your scripts and to ensure high performance.
Especially the performance is very important. The module should prevent loops from running in several scripts that query whether various keys have been pressed. The module has a loop that can be used by all. This main loop is resource-saving and only queries keys that have been registered in the event procedure for observation in the module.
Note: If the dependent resource stops all listeners of that resource will be removed automatically.
How to use
Simple example
Extended example
Method reference
Object NssLibsKeyboardApi
NssLibsKeyboardApi
A standalone object which contains functions to create key listeners.
Getting the object
Methods and properties
onKeyDown(key_hash, on_press_callback)
Creates a new key listener and returnsNssLibsKeyboardKeyListenerApi
object.key_hash
The hash number of the key that should listen to.on_press_callback(listener_api)
The callback which gets fired if the listened key was pressed.listener_api
isNssLibsKeyboardKeyListenerApi
object.
Keys
A table with all key hashes. SeeNssLibsKeyboardKeyMap
for more information or the config.lua file.
Object NssLibsKeyboardKeyListenerApi
NssLibsKeyboardKeyListenerApi
A standalone object which contains some information and functions.
listender_id
number Identifier of key listener.key_hash
number The hash number of the listened key.remove()
function Method to remove the listener.on()
function Method to (re)activate listener.off()
function Method to deactivate listener.
Last updated