![]() |
[New G2O][Client-Side] Key Combination - Printable Version +- Gothic Online Forums (https://archive.gothic-online.com) +-- Forum: Scripting (English) (https://archive.gothic-online.com/forum-11.html) +--- Forum: Resources (https://archive.gothic-online.com/forum-14.html) +---- Forum: Scripts (https://archive.gothic-online.com/forum-17.html) +---- Thread: [New G2O][Client-Side] Key Combination (/thread-2092.html) |
[New G2O][Client-Side] Key Combination - Patrix - 08.06.2017 *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): Squirrel Script
*Another add key shortcut (with multiple): Squirrel Script
*Basic remove key shortcut: Squirrel Script
*Another remove key shortcut: Squirrel Script
RE: [New G2O][Client-Side] Key Combination - Patrix - 23.12.2017 Thread and script have been updated. Changes: -Thread has been completely rewritten. -onRender function has been optimalized (less looping) -Added string replacements. Example: You have L_Ctrl and R_Ctrl, and let's assume that you want to add one combination like: L_CTRL+S or R_CTRL+S. To do that simpler you can use string replacements for keys like: Control, Shift, Alt and Windows. |