Key::bind

From RAGE Multiplayer Wiki
Revision as of 19:36, 27 November 2017 by Fright (talk | contribs) (Better example that presents the new "keyhold" boolean parameter.)

This function binds the key .

Parameters

  • keycode - code of key (Int).
  • keyhold - call function as long as key is held pressed? (Bool)
  • handler - function-handler.

Example

This example calling server event.

Client-Side
// 113 is the F2 key code
mp.keys.bind(113, 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