key_for_str (STRING* string);

This function returns the key scancode for a key name, character or number on an US keyboard. The following strings are converted to scancodes: "a".."z", "0".."9", "f1".."f12", "bksp", "enter", "esc", "alt", "ctrl". "shiftl", "shiftr", "space", "tab", "cuu", "cud", "cur", "cul", "pgup", "pgdn", "home", "end", "ins", "del", "car", "cal", "slash", "equals", "period", "comma", "brackl", "brackr", "semic", "bksl", "apos", "minusc", "grave", "apo", "minus", "plus", "sz", "ae", "ue", "oe", "scrlk", "pause", "caps".

Parameters:

string - key name or character

Returns:

Scancode (see key mapping).

Speed:

Fast

Example:

//Wait until [a] is pressed
while(key_pressed(key_for_str("a")) == 0)
{
  wait(1);
}

See also:

key_pressed, str_for_key, key_set, key_lastpressed, inkey, Key functions and mapping