iDevGames Forums

Full Version: Keys I Can Use In Games
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Are there any keys on the keyboard that I CANNOT use when assigning keys for controls in my game?
power
Very nice Smile. But seriously, am I able to use all the other buttons.
as far as I am aware of
But you should consider stuff like not using Fkeys(becouse of the powerbook thing), and not keys you easily do other stuff with(I remeber a FPS game where you ran with the command key and switched weapons with the Q buttonÖ It didn't work too good.)
Alright thanks.
I read somewhere (here? CMG?) that Cocoa has problems if you press CMD+an arrow key (the arrow key gets "stuck")
actually it is command and any key. but this is only a problem if you input keys a certain way (namely ignoring modifers). I believe arekkusu has the fix for said problem
Some issues I've ran into:

Powerbooks also don't have a separate keypad. Yes, you can hit numlock and use 789-uio-jkl on your keyboard, but it doesn't feel right at all. If you map controls to the keypad, make sure you mirror them to the arrow keys (or just let the player change them.)

You can only have 2 keys pressed simultaneously on your keyboard. The third doesn't register at all. Keys that DON'T count toward this are F-keys, arrow keys and the keypad.
You can fix the Cmd key problem in Cocoa if you subclass NSApp and override sendEvent. I think the thread for that got lost in the downtime, but the code is in Shoot Things if anyone needs it.

So, you can use any key, but you should be aware that not all keyboards have all keys. F13 F14 F15, for example. Or Ã’ is a key on a Spanish keyboard but a dead key combo on a US keyboard.

The number of simultaneous keypresses that register varies depending on the keyboard. It's two on old machines, eight on my powerbook.
arekkusu Wrote:You can fix the Cmd key problem in Cocoa if you subclass NSApp and override sendEvent. I think the thread for that got lost in the downtime, but the code is in Shoot Things if anyone needs it.
Yeah, I think that thread is toast. Here's a quick code snippet to fix the command key-up issue.

Code:
// -paste this anywhere in your Cocoa code
// -to override NSApplication use the Target's inspector to set Principle Class:
// to KeyUpOverride
// -return it to NSApplication if this is removed

@interface KeyUpOverride : NSApplication {
}

@end

@implementation KeyUpOverride

- (void)sendEvent:(NSEvent *)anEvent
{
    if( [anEvent type] == NSKeyUp )
    {
        [[[self mainWindow] firstResponder] tryToPerform:@selector(keyUp:) with:anEvent];
        return;
    }
    [super sendEvent:anEvent];
}

@end
Reference URL's