RawKey()

Syntax

Result = RawKey()
Description
Returns the raw key code of the last Inkey() function call. It's useful for extended (non-ASCII) keys (for example, function keys, arrows, etc).

Parameters

None.

Return value

Returns the key code of the last pressed key.

Remarks

It is not only alphanumeric keys that have an ASCII value. The escape key (27), return key (13) tab key (9) and backspace key (8) are just four examples. A table with ASCII codes you find here.

Example

  If OpenConsole()
    PrintN("Press Escape to exit")
  
    Repeat
      KeyPressed$ = Inkey()
      
      If KeyPressed$ <> ""
        
        PrintN("You pressed: " + KeyPressed$)
        PrintN("It has a raw code of: "+Str(RawKey()))
        
      ElseIf RawKey()
      
        PrintN("You pressed a non ASCII key.")
        PrintN("It has a raw code of: "+Str(RawKey()))
        
      Else
        Delay(20) ; Don't eat all the CPU time, we're on a multitask OS
      EndIf
    
    Until KeyPressed$ = Chr(27) ; Wait until escape is pressed
  EndIf

See Also

Inkey(), Input()

Supported OS

Windows

<- PrintN() - Console Index - ReadConsoleData() ->