Path: ns-mx!uunet!wupost!micro-heart-of-gold.mit.edu!uw-beaver!cornell!vax5.cit.cornell.edu!q4kx
From: q4kx@vax5.cit.cornell.edu (Joel Sumner)
Newsgroups: comp.sys.apple2
Subject: Re: Detecting modifier key presses
Message-ID: <1991Aug14.214411.6829@vax5.cit.cornell.edu>
Date: 15 Aug 91 01:44:10 GMT
References: <1991Aug14.042120.10093@colorado.edu>
Distribution: comp
Organization: CIT, Cornell University
Lines: 52

In article <1991Aug14.042120.10093@colorado.edu>,
hartkopf@spot.Colorado.EDU (Jeff Hartkopf) writes: 
> 
> How do I detect when the user presses a modifier key (control, shift, 
> option, command) from within an NDA written in C?  If necessary I can
> do some sort of polling in the NDA's action routine.
> 

Simple....

In your DAEvent loop, check the byte at location $E0/C025. The following bits
are set in the following conditions...

Bit              Modifier
-------------------------
0      SHIFT Key
1      CONTROL Key
2      CAPS LOCK Key
3      REPEAT Key
4      Keypad Key
5      Updated without keypress
6      OPTION Key
7      APPLE Key


In addition, $E0/C061 has the high bit set if the Open Apple Key is down.
$E0/C062 has the high bit set if the Option key is down.

Source: Fishcer, Michael, "Apple IIgs Technical Reference".  McGraw-Hill.
Pages 372-374.

To do this from Pascal:

TYPE   BytePtr = ^Byte;

Procedure Check;
var    Modifier: BytePtr;
       ModByte:  Byte;
begin
Modifier:=BytePtr($E0C025);
ModByte:=Modifier^;
{do your checking}
end;

Hope this helps.

-- 
Joel Sumner                     GENIE:JOEL.SUMNER     This .sig may not be used
q4kx@cornella.ccs.cornell.edu   q4kx@cornella         for public viewing or
q4kx@vax5.cit.cornell.edu       q4kx@crnlvax5         rebroadcast without the
.....................................................  express written consent
The impedance of absolutely nothing is 377 ohms.      of major league baseball.
