Keys::isDown: Difference between revisions
(Created page with "Returns true if the key specific is pressed. Otherwise, returns false. ==Parameters== * '''keycode''' - code of the key (Number). ==Example== An interval that runs every hal...") |
(Add "See also" section) |
||
| Line 16: | Line 16: | ||
}, 500); | }, 500); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See also== | |||
{{KeyBinding_function_c}} | |||
Revision as of 19:44, 27 November 2017
Returns true if the key specific is pressed. Otherwise, returns false.
Parameters
- keycode - code of the key (Number).
Example
An interval that runs every half-second and outputs the state of the F2 key (pressed or not).
setInterval(() => {
if (mp.keys.isDown(112) === true) { // 112 is the key code for F2
mp.gui.chat.push('F2 key is pressed!');
} else {
mp.gui.chat.push('F2 key is not pressed!');
}
}, 500);