' Reserved and function key combinations can be made using the scan code instead.
' Add function flag values to 128 for Extended key combinations.
{{WhiteEnd}}{{small|NOTE: The above commented table can be copied and pasted directly into the QB64 IDE}}
<center>'''Trapping Ctrl, Alt and Shift key combinations'''</center>
:Keyboard Flag values can be added to monitor more than one control key. For example, flag combination 12 would flag both the Ctrl and Alt key presses. Since the flag already determines the function key to monitor, you don't necessarily have to use it's scancode. You can look for a key combination such as Ctrl + by using the plus key's scancode which is 13 as shown below:
{{WhiteStart}} '''KEY 15, CHR$(4) + CHR$(13)''' 'enabled event when Ctrl and + key are pressed{{WhiteEnd}}
<center>'''Trapping Extended keys (Insert, Home, Page Up, Right Ctrl, R.Alt, and cursor arrow pad)'''</center>
* On a 101-key keyboard, you can trap any of the keys on the dedicated cursorpad by assigning the string to any of the keynumber values from 15 to 25 using the 128 keyboard flag. The cursor arrows are not the same as the pre-assigned number pad arrows:
{{WhiteStart}} '''KEY n, [[CHR$]](128) + [[CHR$]](scancode) ' where n = 15 to 29. See: [[Scancodes]]'''
KEY 15, CHR$(128) + CHR$(75) 'left arrow cursor pad
KEY 16, CHR$(128) + CHR$(72) 'up arrow cursor pad
KEY 17, CHR$(128) + CHR$(77) 'right arrow cursor pad
KEY 18, CHR$(128) + CHR$(80) 'down arrow cursor pad
{{WhiteEnd}}
<center>Use CHR$(0) for the first byte flag for non-function keys. You can substitute a literal [[STRING]] value to trap as shown in Example 2.</center>
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
==Examples==
''Example 1:'' Shows a list of all the string assignments to the function keys F1-F12 (Prints help every time F1 is pressed in the input)
{{CodeStart}}
{{Cl|KEY n|KEY}} 1, "Help"
{{Cl|KEY LIST}}
INPUT "Press F1 or to quit press ENTER: ", a$
{{CodeEnd}}
{{OutputStart}}
F1 Help
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12
Press F1 or to quit press ENTER: HelpHelpHelpHelp
{{OutputEnd}}
''Example 2:'' Trapping the Control + key combination. Use the Control Keyboard flag 4 and + key scancode 13.
{{CodeStart}}
{{Cl|CLS}}
{{Cl|KEY n|KEY}} 15, {{Cl|CHR$}}(4) + {{Cl|CHR$}}(13) 'scancode for "=" or "+" key is 13
{{Cl|ON KEY (n)|ON KEY}}(15) {{Cl|GOSUB}} control 'action of user defined key press
{{Cl|KEY(n)|KEY}}(15) ON 'turn ON event trapping for key combination
{{Cl|PRINT}} "Press Ctrl and plus key combination, escape quits!"