Key::bind: Difference between revisions
MrPancakers (talk | contribs) m (Swapped from old template) |
(Clearified that it's not keyhold but keyup and keydown) |
||
| Line 3: | Line 3: | ||
==Parameters== | ==Parameters== | ||
* '''keycode''' - hexadecimal code of [https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731 key]. | * '''keycode''' - hexadecimal code of [https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731 key]. | ||
* ''' | * '''keydown/keyup''' - truetrigges on key down, false- triggers on key up (bool) | ||
* '''handler''' - function-handler. | * '''handler''' - function-handler. | ||
Revision as of 07:00, 18 December 2018
This function binds the key .
Parameters
- keycode - hexadecimal code of key.
- keydown/keyup - truetrigges on key down, false- triggers on key up (bool)
- handler - function-handler.
Example
This example calling server event.
Client-Side
// 0x71 is the F2 key code
mp.keys.bind(0x71, true, function() {
mp.events.callRemote('keypress:F2'); // Calling server event "keypress:F2"
mp.gui.chat.push('F2 key is pressed. This message will be shown until you release the key, because "keyhold" is true.');
});