You are currently offline, waiting for your internet to reconnect

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

This article was previously published under Q26485
This article has been archived. It is offered "as is" and will no longer be updated.

I am unable to trap the PRINT SCREEN key (on an IBM extendedkeyboard, such as on an IBM AT) when pressed simultaneously with theALT, SHIFT, or CTRL key. However, these can be trapped, with theexception of CTRL+PRINT SCREEN, within the QuickBasic editingenvironment.

These keys can be trapped using GW-Basic Interpreter Version 3.20. Thefollowing is a code example:
KEY 15, CHR$(&H04) + CHR$(&H37)KEY(15) ONON KEY(15) GOSUB keytrapidle: GOTO idlekeytrap:   PRINT "CONTROL+PRINT SCREEN key sequence trapped"   RETURN				
Response:This problem results because the value &H80 is missing from thekeyboardflag argument of the KEY statement. You must add this valuewhenever you trap the PRINT SCREEN key on an extended keyboard.Make sure the Num Lock, Caps Lock, and Scroll Lock keys are all in theoff 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) ONON KEY(15) GOSUB keytrapidleWHILE INKEY$ <> "q"   x = DOEVENTS()WENDENDkeytrapidle:   PRINT "CONTROL+PRINT SCREEN key sequence trapped"   RETURN				

Article ID: 26485 - Last Review: 02/28/2014 00:19:40 - Revision: 1.2

  • kbnosurvey kbarchive KB26485