SCANCODE

SCANCODE

RETURNS THE CODE OF THE KEY CURRENTLY PRESSED (KEYBOARD OR MOUSE)

  • Type: System Variable
  • Parameter: 0
  • Group: System

ACTION

The system variable SCANCODE returns the code of the key currently pressed of the keyboard or of the mouse.

If no key is pressed, SCANCODE is 0.

Remark: there is no memorization process : SCANCODE gives in real time the code of the key currently pressed.

Example of useful codes:

left arrow: 37

up arrow: 38

right arrow: 39

down arrow: 40

space: 32

Enter: 13

b: 66, u: 85, Tab: 9, ...

left key of the mouse: 1

right key of the mouse: 2

SYNTAX: SCANCODE in an expression

USE

  • The system variable SCANCODE is used to know the code of the key currently pressed. It is very useful in the games.

ERROR

  • None.

EXAMPLE

dim x,y : rem 2D coordinates

rem updating the coordinates depending on the arrow keys

if scancode=37 then x=x-1

if scancode=39 then x=x+1

if scancode=38 then y=y-1

if scancode=40 then y=y+1

SEE ALSO

FILTER