keyboard_lastkey

Stores the keycode of the last key pressed.

Syntax:

GML Code Example

keyboard_lastkey;


Returns: Real


Description

This variable refers to the value that keyboard_key was in the previous frame, returning the keycode of that key (all standard keycode constants are returned). This variable is not read only and you can change it, for example to set it to -1 if you handled it already.


Example:

GML Code Example

if (keyboard_lastkey != -1)
    {
    str += keyboard_lastchar;
    keyboard_lastkey = -1;
    }
 

The above code checks to see if the lastkey variable is not equal to -1, and if it is it adds whatever the last key was as a string to the variable "str", then it resets the keyboard_lastkey variable to accept further input.





No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here