Available on:
See also: SCANCODE
Alias: ASCIICODE

ASCII CODE

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.

SYNTAX

 = ASCII CODE


Legend
  • id : identifier
  • type : datatype
  • v : value
  • "..." : string
  • [...] : optional

EXAMPLE

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


ABBREVIATION: AsciiCo

Join BASIC 10Liner Contest with ugBASIC!

An interesting competition is held at the beginning of each year: the BASIC 10Liner Contest. It is possible to use ugBASIC to participate in the next "BASIC10Liner" competition, in the following categories:

  • PUR-120 - A game in 10 lines of max 120 characters (w/abbrev.)
  • EXTREME-256 - A game in 10 lines of max 256 characters (w/abbrev.)
  • SCHAU - Any program in 10 lines of max 256 characters (w/abbrev.)
In order to reduce space you can use this abbreviation for this instruction:

ASCII CODE ↔ AsciiCo

Any problem?

If you have found a problem with this keyword, if you think there is a bug or, more simply, you would like it to be improved, open an issue for this example on GitHub.
Thank you!

open an issue BACK TO KEYWORDS