Solved

Using GetKeys

Posted on 1997-01-04
1
317 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Define unique primary key 9 95
Prevent this page from creating additional dialogs. 3 627
pre4 challenge 19 104
Change to event 1 119
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

821 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