- This wiki is out of date, use the continuation of this wiki instead
Key
From FenixWiki
(Difference between revisions)
Revision as of 21:23, 25 June 2007
Definition
key() is a function that needs a constant or a variable with the scancode or the scancode itself for the key you want to check. The variable ascii shows the scancode of the key currently pressed. This function returns 0 or false if the key is not pressed, 1 or true if it is pressed.
The constants for the keys commonly start with _ + the key. So if you want to check for the letter 'a' to be pressed, you would pass _a to key().
You can find a list of the constants and keycodes here.
Example
program input_test; begin set_mode(320,240,16); set_fps(60,0); while( !key(_esc) ) delete_text(); if( key(_left) && !key(_right) ) write(0,160,120,4, "LEFT"); end; if( key(_right) && !key(_left) ) write(0,160,120,4, "RIGHT"); end; frame; end; exit(); end;
This will output the words LEFT or RIGHT according to the keys you press, or it will quit the program once ESCAPE is pressed.