Re: see if a key is down
Re: see if a key is down
- Subject: Re: see if a key is down
- From: OS X AIBO <email@hidden>
- Date: Tue, 1 Oct 2002 13:03:59 -0700 (PDT)
--- Julien Palmas <email@hidden> wrote:
>
i run a timer and each time it fires, i want to see if a key is down,
>
how can i do ?
Polling for the status of a key is not typically how Cocoa applications
receive events for a number of reasons:
- If the polling rate (the period of your timer) is too long, you can
miss keyboard events.
-If the period is too short, your application consumes a lot of CPU.
-Etc.
For this reason each Cocoa application has an event queue to which
events are added as the user is typing.
Assuming for the moment this is all obvious to you and you still desire
polling for keyboard events (though I still can't imagine why...), you
would need to use the HID Manager, or the helpful set of routines
called HID Utilites built on top of it. This will give you access to
the keyboard as an HID device.
There are carbon samples avaiable at
http://developer.apple.com/samplecode/Sample_Code/Devices_and_Hardware/HID_Manager.htm
but this code will also work for Cocoa applications.
A third party example of HID Manager used in Cocoa application can be
found at
http://www.idevgames.com/content/download.php?page=2&cat=Source+Code
(or thereabouts) called ZedNought.
--Dan
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.