Available on:
Alias: KEYSHIFT

KEY SHIFT

The KEY SHIFT function returns the current status of the various control keys. These keys such as SHIFT or ALT cannot be detected using the standard INKEY$ or SCANCODE functions. But you can easily test for any combination of control keys with just a single call to the KEY SHIFT function. The result is a bit map with the following meaning:

0 -LEFT SHIFT
1 - RIGHT SHIFT
2 - CAPS LOCK
3 - CTRL
4 - LEFT ALT
'5 - RIGHT ALT

If a bit is set to a one, then the associated button has been held down by the user.

Note that not all computers support control keys, nor is it possible to have individual pressure detection. Depending on the target, some of the bits may not be available, or only under certain conditions.

SYNTAX

 = KEY SHIFT


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

EXAMPLE

 CENTER "Press some control keys"
 DO
    LOCATE 14, 4
    PRINT BIN$(KEY SHIFT, 8)
 LOOP


ABBREVIATION: KySHIFT

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:

KEY SHIFT ↔ KySHIFT

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