Key::bind: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
(Easy to use Key Finding tool)
Line 5: Line 5:


==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]. (For an easy to use Key finding tool - try [https://keycode.info/ keycode.info])
* '''keydown/keyup''' - true trigges on keydown, false triggers on keyup (bool)
* '''keydown/keyup''' - true trigges on keydown, false triggers on keyup (bool)
* '''handler''' - function-handler.
* '''handler''' - function-handler.

Revision as of 23:02, 7 January 2021

Client-Side
Function

 JavaScript



Description

This function binds the key .

Parameters

  • keycode - hexadecimal code of key. (For an easy to use Key finding tool - try keycode.info)
  • keydown/keyup - true trigges on keydown, false triggers on keyup (bool)
  • handler - function-handler.

Example

This example calling server event.

// 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.');
});

See also