User Tools

Site Tools


ugbasic:user:kw:key_shift
Translations of this page:


ugBASIC User Manual

KEY SHIFT

SYNTAX

   = KEY SHIFT

PURPOSE

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.

EXAMPLE

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

ABBREVIATION

 KySHIFT

AVAILABLE ON

ALIAS FOR

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