Keyboard – Giavapps Windows API

api_keyboard_check_set_enabled(WindowHandle, Enabled) Enables or disables the keyboard check feature for the specified window. This feature is disabled by default. PLEASE NOTE: you should call keyboard_check_* built-in functions for the GameMaker: Studio window since it usually runs in a different Window Procedure (unless you called api_window_set_giavapps_procedure()).

WindowHandle: it must be a WindowHandle.
Enabled: enables (true) or disables (false) the keyboard check feature.

 

api_keyboard_check_get_enabled(WindowHandle) Returns true if the keyboard check feature is enabled for the specified window or false otherwise.

WindowHandle: it must be a WindowHandle.

 

api_keyboard_check(WindowHandle, Key) Checks to see if a key is held down or not. This function is compatible with vk_* constants of GameMaker: Studio.

WindowHandle: it must be a WindowHandle.
Key: the key to check the down state of.

 

api_keyboard_check_pressed(WindowHandle, Key) Checks to see if a key has been pressed or not. This function is compatible with vk_* constants of GameMaker: Studio.

WindowHandle: it must be a WindowHandle.
Key: the key to check the pressed state of.

 

api_keyboard_check_released(WindowHandle, Key) Checks to see if a key has been released or not. This function is compatible with vk_* constants of GameMaker: Studio.

WindowHandle: it must be a WindowHandle.
Key: the key to check the released state of.

 

api_keyboard_key_press(WindowHandle, Key) Simulates (internally) the press of any key on the keyboard. This function is compatible with vk_* constants of GameMaker: Studio. If Key argument is vk_anykey Giavapps Windows API simulates (internally) the press of all the keys on the keyboard.

WindowHandle: it must be a WindowHandle.
Key: the key to simulate a press of.

 

api_keyboard_key_release(WindowHandle, Key) Simulates (internally) the release of any key on the keyboard. This function is compatible with vk_* constants of GameMaker: Studio. If Key argument is vk_anykey Giavapps Windows API simulates (internally) the release of all the keys on the keyboard.

WindowHandle: it must be a WindowHandle.
Key: the key to simulate a release of.

 

api_keyboard_clear(WindowHandle) Clears (internally) all states of the keys on the keyboard for the specified window.

 

Code Examples

 

Enabling the Keyboard Check Feature

 

api_keyboard_check_set_enabled(window1,1);
api_keyboard_check_set_enabled(window2,1);

 

Checking Key Presses In Different Windows

 

//WINDOW 1
if(api_keyboard_check_pressed(window1,vk_space))
{
api_messagebox(window1,"SPACE PRESSED IN WINDOW 1!","PRESSED!",MB_OK);
}

//WINDOW 2
if(api_keyboard_check_pressed(window2,vk_space))
{
api_messagebox(window2,"SPACE PRESSED IN WINDOW 2!","PRESSED!",MB_OK);
}

 

I am Luigi Piscopo, also known as DJ GiDeejay / Producer / Remixer in the music world. I am a Producer with a lot of experience in photo editing, video editing, audio editing, graphic design, web design, programming and promotion.

Leave a Reply

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

*