Microsoft KB Archive/26485

= Trapping ALT+, SHIFT+, or CTRL+PRINT SCREEN, &H80 Key Flag =

Article ID: 26485

Article Last Modified on 11/21/2006



This article was previously published under Q26485



SUMMARY
Problem:

I am unable to trap the PRINT SCREEN key (on an IBM extended keyboard, such as on an IBM AT) when pressed simultaneously with the ALT, SHIFT, or CTRL key. However, these can be trapped, with the exception of CTRL+PRINT SCREEN, within the QuickBasic editing environment.

These keys can be trapped using GW-Basic Interpreter Version 3.20. The following is a code example: KEY 15, CHR$(&H04) + CHR$(&H37) KEY(15) ON ON KEY(15) GOSUB keytrap idle: GOTO idle keytrap:

PRINT &quot;CONTROL+PRINT SCREEN key sequence trapped&quot; RETURN Response: This problem results because the value &H80 is missing from the keyboardflag argument of the KEY statement. You must add this value whenever you trap the PRINT SCREEN key on an extended keyboard. Make sure the Num Lock, Caps Lock, and Scroll Lock keys are all in the off position when you are trapping keys with this method.

The correct method for trapping the key is as follows: KEY 15, CHR$(&H80 + &H4) + CHR$(&H37) KEY(15) ON

ON KEY(15) GOSUB keytrapidle

WHILE INKEY$ <> &quot;q&quot;

x = DOEVENTS

WEND

END

keytrapidle:

PRINT &quot;CONTROL+PRINT SCREEN key sequence trapped&quot; RETURN

Additional query words: QuickBas

Keywords: KB26485

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.