Extended keys are 2 bytes in length, the first byte is an ESC character,
which can be ignored, and the second byte is the virtual key code.
In the Windows version, you can add the option to trap all keys, including
shift, ctrl, key, caps lock, num lock, scroll lock, and that PopupMenu key (if
you're using a Windows specific keyboard, no not the StartMenu Key, the other one, if it
exists on your keyboard). You can turn on/off this option anytime you wish:
$OPTION INKEY$ TRAPALL
' trap all keys including shift, alt, ctrl, caps/num/scroll lock
' and the PopupMenu key
$OPTION INKEY$ DEFAULT
' traps all extended keys except the ones listed above
If you've used QBasic, you probably know the scan codes inside out, so all the
virtual key codes that Rapid-Q dishes out is exactly the same scan codes you'd
see in QBasic. The following code is an example of how to trap/parse extended keys,
particularly the arrow keys:
DO
DO
A$ = INKEY$
LOOP UNTIL LEN(A$)
IF LEN(A$) = 2 THEN
SELECT CASE RIGHT$(A$, 1)
CASE "P"
PRINT "Down arrow key pressed."
CASE "H"
PRINT "Up arrow key pressed."
CASE "M"
PRINT "Right arrow key pressed."
CASE "K"
PRINT "Left arrow key pressed."
CASE ELSE
PRINT "Extended key "; A$
END SELECT
END IF
LOOP UNTIL A$ = CHR$(27)
Even if you didn't know the scan codes, you can look at the output of the
above example to figure them out.
6.6 Mixing CONSOLE with GUI
As you've noticed in the above example, we've mixed some CONSOLE operations
with GUI ones. This is perfectly valid as long as you've compiled your
application as CONSOLE. Under Linux/Unix there are some strange differences,
please refer to the compatibilty guide for more information. For example,
a GUI application for Linux/Unix can perform some CONSOLE operations such as
PRINT, INPUT, and CLS without being compiled as CONSOLE.
6.7 Linux/Unix Console
Since most terminals are different, some console features will not work.
If your terminal does not support color, none will be displayed.
You don't need to worry about these issues, as Rapid-Q performs all proper error checking
for you. The same can be said for extended keys, some terminals don't support
certain keys. However, most terminals do support the arrow keys and Page up/down keys.
You're almost guaranteed that those keys will work for most terminals.