This wiki is out of date, use the continuation of this wiki instead

Key

From FenixWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 22:53, 25 June 2007 (edit)
87.177.23.239 (Talk)

← Previous diff
Revision as of 00:01, 26 June 2007 (edit) (undo)
Sandman (Talk | contribs)

Next diff →
Line 1: Line 1:
-[[Category:Initialization]]+[[Category:functions]]
-=== 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 [[constant]]s for the keys commonly start with _ + the key.+==Definition==
-So if you want to check for the letter 'a' to be pressed, you would pass _a to '''key();'''.+'''INT''' Key( <'''INT''' keycode> )
-Take a look at the [[scancodes]] for a complete list.+Checks if a certain key is being pressed.
-=== Example ===+== Parameters ==
 +{|
 +| '''INT''' keycode || - The keycode of the key to be checked.
 +|}
 + 
 +== Returns ==
 +'''INT''' : [[true]]/[[false]]: Whether the key is being pressed.
 + 
 +== Notes ==
 +Take a look at the [[keycodes]] for a complete list.
 + 
 +== Example ==
<pre> <pre>
-program input_test;+Program input_test;
- begin+Begin
- set_mode(320,240,16);+
- set_fps(60,0);+
- while( !key(_esc) )+ While( !key(_esc) )
- delete_text();+ delete_text();
- if( key(_left) && !key(_right) ) + if( key(_left) && !key(_right) )
- write(0,160,120,4, "LEFT");+ write(0,160,120,4, "LEFT");
- end;+ end;
- if( key(_right) && !key(_left) ) + if( key(_right) && !key(_left) )
- write(0,160,120,4, "RIGHT"); + write(0,160,120,4, "RIGHT");
- end;+ end;
- frame;+ frame;
- end;+
- exit();+ End;
- end;+ 
 + exit();
 + 
 +End
</pre> </pre>
 +Used in example: [[delete_text]](), [[write]](), [[exit]]()
 +
This will output the words LEFT or RIGHT according to the keys you press, This will output the words LEFT or RIGHT according to the keys you press,
or it will quit the program once ESCAPE is pressed. or it will quit the program once ESCAPE is pressed.

Revision as of 00:01, 26 June 2007


Contents

Definition

INT Key( <INT keycode> )

Checks if a certain key is being pressed.

Parameters

INT keycode - The keycode of the key to be checked.

Returns

INT : true/false: Whether the key is being pressed.

Notes

Take a look at the keycodes for a complete list.

Example

Program input_test;
Begin

    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

Used in example: delete_text(), write(), exit()

This will output the words LEFT or RIGHT according to the keys you press, or it will quit the program once ESCAPE is pressed.

Personal tools