IsKeyPressed(eKeyCode)
Tests whether the supplied key on the keyboard is currently pressed down
or not. You could use this to move an object while the player holds an
arrow key down, for instance.
KEYCODE is one of the ASCII codes, with some limitations:
since it tests the raw state of the key, you CANNOT pass the Ctrl+(A-Z)
or Alt+(A-Z) codes (since they are key combinations). You can, however,
use some extra codes which are listed at the bottom of the section.
Returns 1 if the key is currently pressed, 0 if not.
NOTE: The numeric keypad can have inconsistent keycodes between IsKeyPressed
and on_key_press. With IsKeyPressed, the numeric keypad always uses keycodes in the 370-381
range. on_key_press, however, passes different values if Num Lock is on since the key
presses are interpreted as the number key rather than the arrow key.
Example:
if (IsKeyPressed(eKeyUpArrow) == 1)
cEgo.Walk(cEgo.x, cEgo.y+3);
will move the character EGO upwards 3 pixels when the up arrow is pressed.
See Also: Mouse.IsButtonDown
|