Keys::isDown
Jump to navigation
Jump to search
Function to check if specific key is pressed down.
Syntax
mp.keys.isDown(keyCode);
Required Arguments
- keyCode: Number - code of the key.
Return Value
- Boolean -
true
if the key specified is pressed, Otherwisefalse
.
Example
An interval that runs every half-second and outputs the state of the F2 key (pressed or not).
Client-Side
setInterval(() => {
if (mp.keys.isDown(113) === true) { // 113 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);