Key::bind: Difference between revisions

From RAGE Multiplayer Wiki
m (Swapped from old template)
Line 18: Line 18:


==See also==
==See also==
{{KeyBinding_function_c}}
{{Keys_functions_c}}

Revision as of 02:11, 13 May 2018

This function binds the key .

Parameters

  • keycode - hexadecimal code of key.
  • keyhold - call function as long as key is held pressed? (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.');
});

See also