Table of Contents

ugBASIC User Manual

ASCII CODE

SYNTAX

   = ASCII CODE

PURPOSE

The ASCII CODE command capture a keystroke “on the Fly”, and return the equivalent ASCII code instead of internal SCANCODE. This command is a fundamental tool for making programs more interactive. It allows you to read a character typed by the user without having to press the enter key.

Unlike other input commands, ASCII CODE does not require the user to press Enter to send the character, while the typed character is not displayed on the screen. It return directly the ASCII code of the typed character, or a special value (0) if no key was pressed. It is equivalent to write ASC( INKEY$() ), but faster, since no string is created. Note that the reading speed could vary significantly depending on the target.

This command allows you to create simple games in which the user must press specific keys to control a character or object. It can be used to create more responsive user interfaces, in which the user can interact with the program in real time or that respond to certain key combinations, automating certain operations.

Due to the limitations of 7-bit ASCII encoding, ASCII CODE could only read characters in the standard ASCII set. Use SCANCODE if you need to be able to detect any key.

EXAMPLE

  IF ASCII CODE = 42 THEN
     PRINT "ASTERISK has been pressed!"
  ENDIF

ABBREVIATION

 AsciiCo

AVAILABLE ON

SEE ALSO

SCANCODE

ALIAS FOR

ASCIICODE

ANY PROBLEM?

If you have encountered a problem using this command, if you think there is a bug or the explanation is unclear, please open an issue for this keyword on GitHub. Thank you!

POWERED BY