Solved

Using GetKeys

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

803 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