Keyboard Input

1.Overview

Keyboard a core input device for desktop/laptop gamers. Some devices support on-screen keyboards as well as some game devices also support activate keyboard usage(versus only allowed on keyboard entry popups). 

2.Keyboard Functions

gpe.check_keyboard_down(keyId)

Returns true or false if the key is being pressed now.

Scope: GPE

Return type : bool

Parameters:

  • int keyId – The constant assigned to the keyboard button. Also procecessed the nobutton and anybutton cases.

 

gpe.check_keyboard_pressed(keyId)

Returns true or false if the key was just pressed in frame.
Scope: GPE

Return type : bool

Parameters:

  • int keyId – The constant assigned to the keyboard button. Also procecessed the nobutton and anybutton cases.

 

gpe.check_keyboard_released(keyId)

Returns true or false if the key was just released in frame.
Scope: GPE

Return type : bool

Parameters:

  • int keyId – The constant assigned to the keyboard button. Also procecessed the nobutton and anybutton cases.

 

3.Keyboard Constants

In GPE we utilize constants with the “kb_” prefix for handling button input. It is important to know their importance when referencing Keyboard Buttons and their states throughout your games

Here is a complete list of the kb_ constants:

ConstantDescription
kb_anykeyUsed to check for any key on the keyboard.
kb_nokeyUsed to check for all keys being unused.
kb_leftRepresents the left arrow key.
kb_rightRepresents the right arrow key.
kb_upRepresents the up arrow key.
kb_downRepresents the down arrow key.
kb_0Represents the 0 key typically on the upper region of the keyboard.
kb_1Represents the 1 key typically on the upper region of the keyboard.
kb_2Represents the 2 key typically on the upper region of the keyboard.
kb_3Represents the 3 key typically on the upper region of the keyboard.
kb_4Represents the 4 key typically on the upper region of the keyboard.
kb_5Represents the 5 key typically on the upper region of the keyboard.
kb_6Represents the 6 key typically on the upper region of the keyboard.
kb_7Represents the 7 key typically on the upper region of the keyboard.
kb_8Represents the 8 key typically on the upper region of the keyboard.
kb_9Represents the 9 key typically on the upper region of the keyboard.
kb_backspaceRepresents the BSC key on most keyboards.
kb_tabRepresents the TAB key on most keyboards.
kb_enterRepresents the ENTER/RETURN key on most keyboards.
kb_spaceRepresents the SPACE key on most keyboards.
kb_pauseRepresents the Pause/Break key on most keyboards.
kb_capsRepresents the Caps/Lock key on most keyboards.
kb_deleteRepresents the DELETE key on most keyboards.
kb_escRepresents the ESC key on most keyboards.
kb_aRepresents the "A" Key on many standard keyboards.
kb_bRepresents the "B" Key on many standard keyboards.
kb_cRepresents the "C" Key on many standard keyboards.
kb_dRepresents the "D" Key on many standard keyboards.
kb_eRepresents the "E" Key on many standard keyboards.
kb_fRepresents the "F" Key on many standard keyboards.
kb_gRepresents the "G" Key on many standard keyboards.
kb_hRepresents the "H" Key on many standard keyboards.
kb_iRepresents the "I" Key on many standard keyboards.
kb_jRepresents the "J" Key on many standard keyboards.
kb_kRepresents the "K" Key on many standard keyboards.
kb_lRepresents the "L" Key on many standard keyboards.
gp_mRepresents the "M" Key on many standard keyboards.
kb_nRepresents the "N" Key on many standard keyboards.
kb_oRepresents the "O" Key on many standard keyboards.
kb_pRepresents the "P" Key on many standard keyboards.
kb_qRepresents the "Q" Key on many standard keyboards.
kb_rRepresents the "R" Key on many standard keyboards.
kb_sRepresents the "S" Key on many standard keyboards.
kb_tRepresents the "T" Key on many standard keyboards.
kb_uRepresents the "U" Key on many standard keyboards.
kb_vRepresents the "V" Key on many standard keyboards.
kb_wRepresents the "W" Key on many standard keyboards.
kb_xRepresents the "X" Key on many standard keyboards.
kb_yRepresents the "Y" Key on many standard keyboards.
kb_zRepresents the "Z" Key on many standard keyboards.
kb_np0Represents the "0" Key on NumberPad of many standard keyboards.
kb_np1Represents the "1" Key on NumberPad of many standard keyboards.
kb_np2Represents the "2" Key on NumberPad of many standard keyboards.
kb_np3Represents the "3" Key on NumberPad of many standard keyboards.
kb_np4Represents the "4" Key on NumberPad of many standard keyboards.
kb_np5Represents the "5" Key on NumberPad of many standard keyboards.
kb_np6Represents the "6" Key on NumberPad of many standard keyboards.
kb_np7Represents the "7" Key on NumberPad of many standard keyboards.
kb_np8Represents the "8" Key on NumberPad of many standard keyboards.
kb_np9Represents the "9" Key on NumberPad of many standard keyboards.
kb_f1Represents the "F1" function key on of many standard keyboards.
kb_f2Represents the "F2" function key on of many standard keyboards.
kb_f3Represents the "F3" function key on of many standard keyboards.
kb_f4Represents the "F4" function key on of many standard keyboards.
kb_f5Represents the "F5" function key on of many standard keyboards.
kb_f6Represents the "F6" function key on of many standard keyboards.
kb_f7Represents the "F7" function key on of many standard keyboards.
kb_f8Represents the "F8" function key on of many standard keyboards.
kb_f9Represents the "F9" function key on of many standard keyboards.
kb_f10Represents the "F11" function key on of many standard keyboards.
kb_f11Represents the "F11" function key on of many standard keyboards.
kb_f12Represents the "F12" function key on of many standard keyboards.

*These are all of the constants supported in in the current version of GPE. If any of the keys do not process properly, please notify us immediately and we will make sure there is no cross-platform issues preventing a singularity. *

4.Legacy Keyboard Constants

In older versions of GPE(1.1.1 and earlier) we previously used the “gp_” prefix to reference keyboard input. Although, still supported;  it is unadvised to further their usage. For those “too deep in the old ways” here is the list below.

ConstantDescription
gp_anykeyUsed to check for any key on the keyboard.
gp_nokeyUsed to check for all keys being unused.
gp_leftRepresents the left arrow key.
gp_rightRepresents the right arrow key.
gp_upRepresents the up arrow key.
gp_downRepresents the down arrow key.
gp_0Represents the 0 key typically on the upper region of the keyboard.
gp_1Represents the 1 key typically on the upper region of the keyboard.
gp_2Represents the 2 key typically on the upper region of the keyboard.
gp_3Represents the 3 key typically on the upper region of the keyboard.
gp_4Represents the 4 key typically on the upper region of the keyboard.
gp_5Represents the 5 key typically on the upper region of the keyboard.
gp_6Represents the 6 key typically on the upper region of the keyboard.
gp_7Represents the 7 key typically on the upper region of the keyboard.
gp_8Represents the 8 key typically on the upper region of the keyboard.
gp_9Represents the 9 key typically on the upper region of the keyboard.
gp_backspaceRepresents the BSC key on most keyboards.
gp_tabRepresents the TAB key on most keyboards.
gp_enterRepresents the ENTER/RETURN key on most keyboards.
gp_spaceRepresents the SPACE key on most keyboards.
gp_pauseRepresents the Pause/Break key on most keyboards.
gp_capsRepresents the Caps/Lock key on most keyboards.
gp_deleteRepresents the DELETE key on most keyboards.
gp_escRepresents the ESC key on most keyboards.
gp_aRepresents the "A" Key on many standard keyboards.
gp_bRepresents the "B" Key on many standard keyboards.
gp_cRepresents the "C" Key on many standard keyboards.
gp_dRepresents the "D" Key on many standard keyboards.
gp_eRepresents the "E" Key on many standard keyboards.
gp_fRepresents the "F" Key on many standard keyboards.
gp_gRepresents the "G" Key on many standard keyboards.
gp_hRepresents the "H" Key on many standard keyboards.
gp_iRepresents the "I" Key on many standard keyboards.
gp_jRepresents the "J" Key on many standard keyboards.
gp_kRepresents the "K" Key on many standard keyboards.
gp_lRepresents the "L" Key on many standard keyboards.
gp_mRepresents the "M" Key on many standard keyboards.
gp_nRepresents the "N" Key on many standard keyboards.
gp_oRepresents the "O" Key on many standard keyboards.
gp_pRepresents the "P" Key on many standard keyboards.
gp_qRepresents the "Q" Key on many standard keyboards.
gp_rRepresents the "R" Key on many standard keyboards.
gp_sRepresents the "S" Key on many standard keyboards.
gp_tRepresents the "T" Key on many standard keyboards.
gp_uRepresents the "U" Key on many standard keyboards.
gp_vRepresents the "V" Key on many standard keyboards.
gp_wRepresents the "W" Key on many standard keyboards.
gp_xRepresents the "X" Key on many standard keyboards.
gp_yRepresents the "Y" Key on many standard keyboards.
gp_zRepresents the "Z" Key on many standard keyboards.
gp_np0Represents the "0" Key on NumberPad of many standard keyboards.
gp_np1Represents the "1" Key on NumberPad of many standard keyboards.
gp_np2Represents the "2" Key on NumberPad of many standard keyboards.
gp_np3Represents the "3" Key on NumberPad of many standard keyboards.
gp_np4Represents the "4" Key on NumberPad of many standard keyboards.
gp_np5Represents the "5" Key on NumberPad of many standard keyboards.
gp_np6Represents the "6" Key on NumberPad of many standard keyboards.
gp_np7Represents the "7" Key on NumberPad of many standard keyboards.
gp_np8Represents the "8" Key on NumberPad of many standard keyboards.
gp_np9Represents the "9" Key on NumberPad of many standard keyboards.
gp_f1Represents the "F1" function key on of many standard keyboards.
gp_f2Represents the "F2" function key on of many standard keyboards.
gp_f3Represents the "F3" function key on of many standard keyboards.
gp_f4Represents the "F4" function key on of many standard keyboards.
gp_f5Represents the "F5" function key on of many standard keyboards.
gp_f6Represents the "F6" function key on of many standard keyboards.
gp_f7Represents the "F7" function key on of many standard keyboards.
gp_f8Represents the "F8" function key on of many standard keyboards.
gp_f9Represents the "F9" function key on of many standard keyboards.
gp_f10Represents the "F11" function key on of many standard keyboards.
gp_f11Represents the "F11" function key on of many standard keyboards.
gp_f12Represents the "F12" function key on of many standard keyboards.

5.Examples

Ripped from the Basic 2d example:

This moves the left-paddle up and down depending on keyboard input:

 

Suggest Edit