home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / mac / programm / 13155 < prev    next >
Encoding:
Text File  |  1992-07-29  |  1.5 KB  |  42 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!cs.utexas.edu!sdd.hp.com!mips!darwin.sura.net!convex!news.utdallas.edu!corpgate!bnrgate!bmers95!usenet
  3. From: ross@bnr.ca (Ross Brown)
  4. Subject: Re: Q: Checking for modif keys on app startup
  5. Message-ID: <1992Jul29.144320.18410@bmers95.bnr.ca>
  6. Sender: usenet@bmers95.bnr.ca
  7. Organization: Bell-Northern Research
  8. References: <1992Jul28.162138.9681@leland.Stanford.EDU> <70554@apple.Apple.COM> <Bs55zL.1GD@taligent.com>
  9. Date: Wed, 29 Jul 92 14:43:20 GMT
  10. Lines: 30
  11.  
  12. In article <Bs55zL.1GD@taligent.com> keith@taligent.com (Keith Rollin) writes:
  13. >>[previous post deleted]
  14. >I don't really know if either method is better than the other. The only thing
  15. I
  16. >can think of is that some people (myself included) have a hard time trying to
  17. >figure out how to read the KeyMap variable (I program in C, which defines
  18. KeyMap
  19. >as 4 longs, and not a packed array of 128 Booleans).
  20.  
  21. How often do I get the chance to help Keith Rollin out?  :-)
  22.  
  23. Boolean    IsKeyDown( short keyCode )
  24. {
  25.     char    keyMap[ 16 ];
  26.     
  27.     GetKeys( (KeyMap) keyMap );
  28.     
  29.     if( keyMap[ keyCode >> 3 ] & ( 1 << ( keyCode & 0x7 ) ) )
  30.         return true;
  31.     else
  32.         return false;
  33.  
  34. }
  35.  
  36. W. Ross Brown                 | from Brown's Dictionary of Psychic Kinematics:
  37. Advisor, Telemanagement Svcs. |                          ex-hil'a-ra'tion (n.)
  38. Bell-Northern Research Ltd.   |                The rate of change of felicity.
  39. Ottawa, Ontario, Canada       | ----------------------------------------------
  40. ross@bnr.ca                   |      Any opinion expressed is mine, not BNR's.
  41.  
  42.