2+ keys down?
Hi all!
I was just wondering - how the heck do you do this? I use GetKeys for input into my Carbon-based application, and I just noticed that GetKeys only supports 2 (or was it three) keys down simultaneously.
I know that most of the games out there do support that, I thought I'd ask you how you do it. For instance, I need people to be able to jump and hold the jump button, push left to run left while mid-air, but now that means that I can't shoot! Bad. 
Any thoughts?
I was just wondering - how the heck do you do this? I use GetKeys for input into my Carbon-based application, and I just noticed that GetKeys only supports 2 (or was it three) keys down simultaneously.


Any thoughts?
In my carbon game I use this code to do keys.
On the GetNextEvent you might want to mask the events only to key events. To get modifier keys you need add something to it.
This stuff works good for me.
-Justin
Code:
if ( GetNextEvent(everyEvent, &event) )
{
if(event.message == NULL)
return;
theKey = (event.message & keyCodeMask) >> 8;
isDown = (event.what != keyUp);
On the GetNextEvent you might want to mask the events only to key events. To get modifier keys you need add something to it.
Code:
GetKeys(keyMap);
if ( IsKeyDown(keyMap, keyCommand) )
{
This stuff works good for me.
-Justin
GetKeys() supports as many keys simultaneously as your keyboard hardware. On recent keyboards you can often detect five or six non-modifier keys at once, but since certain keys block certain other keys you might have as few as two. Which keys affect which depends on the keyboard matrix layout.
Modifiers (command, option, shift, control and caps lock) aren't affected by this limitation, so they're good candidates for keys that you never want to fail (fire buttons, for example).
You could switch to an event based mechanism to try to avoid these problems, but I personally have never had any real trouble with GetKeys().
Modifiers (command, option, shift, control and caps lock) aren't affected by this limitation, so they're good candidates for keys that you never want to fail (fire buttons, for example).
You could switch to an event based mechanism to try to avoid these problems, but I personally have never had any real trouble with GetKeys().
Possibly Related Threads...
Thread: | Author | Replies: | Views: | Last Post | |
Spaces on Snow Leopard and ctrl/arrow keys | GolfHacker | 19 | 26,739 |
Dec 4, 2012 03:18 PM Last Post: bmantzey |
|
Multiple Keys down in SDL | silver9172 | 2 | 7,377 |
May 30, 2009 06:16 PM Last Post: scgames |
|
[NSEvent keyCode] to actual keys? | teknein | 8 | 16,561 |
Sep 5, 2007 07:27 AM Last Post: teknein |
|
Keys ......again | Coin | 7 | 9,068 |
Jan 29, 2005 09:38 PM Last Post: belthaczar |
|
Keys I Can Use In Games | Nick | 10 | 8,305 |
Jul 22, 2004 11:49 PM Last Post: AnotherJake |