Solved

Using GetKeys

Posted on 1997-01-04
1
306 Views
Last Modified: 2013-12-26
I need to know how to use GetKeys in a program made in C. How can I get individual keys? Useualy It just returns them all mixed up. ie:1 0 0 0 0 0 0 0 would be 8 elements of an aray.10000000 is how it gets returned. 8 bits instead of 8 elements.
0
Comment
Question by:simap
1 Comment
 

Accepted Solution

by:
gregj earned 100 total points
ID: 1291753
Usually what you need from GetKeys is to find out if a specific key is pressed. You need the key scan code, which are documented in Inside Macintosh (Event Manager) and Think Reference.

There is a complete explanation of the keymap structure in Inside Macintosh.

This function is what I and most everyone else uses:



Boolean IsKeyDown(unsigned short scancode )
{
      unsigned char keymap[16];

      GetKeys( (long *) keymap);
      return ( ( keymap[scancode>>3] >> (scancode & 7) ) & 1);
}


0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now