Solved

Using GetKeys

Posted on 1997-01-04
1
299 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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
xyBalance chalenge 58 88
Creating Labels and Frequency list style reports in SAS code 9 88
NotAlone Challenge 20 70
Fibonacci challenge 11 82
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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 this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

771 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

10 Experts available now in Live!

Get 1:1 Help Now