Skip to content

keyboard_check

drewmccluskey edited this page Feb 12, 2019 · 4 revisions

keyboard_check

Returns if a specified keyboard key is being held down

Syntax:

keyboard_check(key)
Argument Description
Keys key The key button to being checked if is held down

Returns: bool

Description:

This function will check if a specified key is currently held down and then runs the code if so each step the key is held down. It is useful for controlling characters with keys such as the W, A, S, D pattern or the arrow keys.

Example:

if (keyboard_check(Keys.D))
{
    Position.X += 10;
}

This code will move the object to the right when the D key is held down.

Example 2:

if (keyboard_check(Keys.Up))
{
    Position.Y -= 5;
}

This code will move the object up when the up arrow key is held down.

Back to Keyboard

Clone this wiki locally