*Introduction:
NOTE! You have to enable event onRender via enableEvent_Render function
Info: This script is stable and propably doesn't have any bugs.
Hi there, lately i was working on some simple script, which allows to register some key shortcuts in game and i want to share my work.
It's easy to use, for example: you can bind ALT+F4 shortcut to quickly close the game. Also if you want to add combination like:
CTRL+WINDOWS (L_CTRL or R_CTRL) + (L_WINDOWS or R_WINDOWS) you can use string replacements for keys like:
CONTROL, ALT, SHIFT and WINDOWS.
License
Download
*List of functions:
void addKeyCombination(array keys, func callback, [[optional: bool multiple)
void removeKeyCombination(array keys, [[optional: func callback, bool multiple ]])
*List of string replacements: (they're blind to letter capitalization)
"Windows" // This key replacement should be used when you want to add shortcut which is using one of the Windows keys (Left or Right).
"Control" // This key replacement should be used when you want to add shortcut which is using one of the Control keys (Left or Right).
"Ctrl" // This is the alias for "Control".
"Alt" // This key replacement should be used when you want to add shortcut which is using one of the Alt keys (Left or Right).
"Shift" // This key replacement should be used when you want to add shortcut which is using one of the Shift keys (Left or Right).
*Function (addKeyCombination, removeKeyCombination) parameters description:
Info: The more arguments you give in removeKeyCombination function, the more precise you remove bound key shortcut(s).
NOTE! You can skip (set as null) every argument in calling removeKeyCombination function.
// Required parameters for addKeyCombination
array keys // Array of shortcut keys.
void callback // The function which will be called.
// Optional parameters for addKeyCombination
bool multiple /* If this argument is equal true (default is false),
when you hold keys, function will be called more than once. */
*Examples:
*Basic add key shortcut (fast closing game):
*Another add key shortcut (with multiple):
*Basic remove key shortcut:
*Another remove key shortcut:
NOTE! You have to enable event onRender via enableEvent_Render function
Info: This script is stable and propably doesn't have any bugs.
Hi there, lately i was working on some simple script, which allows to register some key shortcuts in game and i want to share my work.
It's easy to use, for example: you can bind ALT+F4 shortcut to quickly close the game. Also if you want to add combination like:
CTRL+WINDOWS (L_CTRL or R_CTRL) + (L_WINDOWS or R_WINDOWS) you can use string replacements for keys like:
CONTROL, ALT, SHIFT and WINDOWS.
License
Download
*List of functions:
void addKeyCombination(array keys, func callback, [[optional: bool multiple)
void removeKeyCombination(array keys, [[optional: func callback, bool multiple ]])
*List of string replacements: (they're blind to letter capitalization)
"Windows" // This key replacement should be used when you want to add shortcut which is using one of the Windows keys (Left or Right).
"Control" // This key replacement should be used when you want to add shortcut which is using one of the Control keys (Left or Right).
"Ctrl" // This is the alias for "Control".
"Alt" // This key replacement should be used when you want to add shortcut which is using one of the Alt keys (Left or Right).
"Shift" // This key replacement should be used when you want to add shortcut which is using one of the Shift keys (Left or Right).
*Function (addKeyCombination, removeKeyCombination) parameters description:
Info: The more arguments you give in removeKeyCombination function, the more precise you remove bound key shortcut(s).
NOTE! You can skip (set as null) every argument in calling removeKeyCombination function.
// Required parameters for addKeyCombination
array keys // Array of shortcut keys.
void callback // The function which will be called.
// Optional parameters for addKeyCombination
bool multiple /* If this argument is equal true (default is false),
when you hold keys, function will be called more than once. */
*Examples:
*Basic add key shortcut (fast closing game):
Squirrel Script
- addKeyCombination([KEY_LMENU,KEY_F4], exitGame)
*Another add key shortcut (with multiple):
Squirrel Script
- addKeyCombination(["Ctrl",KEY_S], function()
- { // adding LCTRL+S or RCTRL+S combination
- print("Spam") // this will pring msg in console (~) and this function will be called more than once when you hold keys.
- },true)
*Basic remove key shortcut:
Squirrel Script
- // dummy example adding and removing combination
- addKeyCombination([KEY_LMENU,KEY_F4], exitGame)
- removeKeyCombination([KEY_LMENU,KEY_F4],exitGame)
*Another remove key shortcut:
Squirrel Script
- addKeyCombination([KEY_Q,KEY_E],function()
- {
- print("This msg will be printed only once!") // printing msg in console(~)
- removeKeyCombination([KEY_Q,KEY_E]) // removing every combination Q+E
- })