ord

Returns the Unicode value code of the first character in the given string.

Syntax:

GML Code Example

ord(str);


Argument Description
str The string with which to find the Unicode code.


Returns: Real


Description

This function takes a string (of a single character only) and returns the Unicode value for that character. In this way you can, for example, store as integers individual key presses, and it is most commonly used by the keyboard_check() functions.


Example:

GML Code Example

if keyboard_check(ord("W"))
    {
    y -= 4;
    }
 

This will move the calling instance four pixels upwards if the key W is held down.


Back: Strings
Next: real



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