Skip to content

keyboard_key_press

drewmccluskey edited this page Feb 12, 2019 · 1 revision

keyboard_key_press

Sets a keys pushed state to true

Syntax:

keyboard_key_press(key)
Argument Description
Keys key The keyboard button being set to true

Returns: void

Description:

This function will set a key to a state of true. This allows the user to have the same functions happen when a user would normally push a key. For instance pressing the W button may make a character jump, but the programmer may want W or Space to make him jump. The user could then make it that when the spacebar is pressed the W event is triggered.

Example:

if (keyboard_check_pressed(Keys.Esc))
{
    room_restart();
}
if (keyboard_check_pressed(Keys.R))
{
    keyboard_key_press(Keys.Esc)
}

This code will restart the game room when the user presses the Esc key as well as when the user pressed the R key.

Back to Keyboard

Clone this wiki locally