keyboard_check() (Game Maker)
( Game Maker 6.1, 7 )
keyboard_check - check to see if a key is held down
Description
bool = keyboard_check ( keycode )
- bool - or 1
- keycode - keycode constant of key to check
keyboard_check() checks to see if a key is held down and returns a 1 if it is, and a if it is not. It accepts the keycode of the key to check as its argument.
To find the proper keycode, Game Maker has a number of keycode constants for the most commonly used keys. If you need a letter, you can use ord().
Examples
Example of Use
if(keyboard_check(vk_space))
{
show_message("Don't press space.");
}
In this example, keyboard_check() is used to see if space is held down. It it is, a message will pop up.
Using Ord
If you need a to check a key that is not represented in a keycode constant, such as a letter, you can use ord() instead.
if(keyboard_check(ord("W")))
{
show_message("You have pressed w");
}
Related Pages
Similar To
- Basic4GL : KeyDown(), ScanKeyDown()
- Brutus2D : key.Pressed()
page revision: 21, last edited: 08 Feb 2014 02:32