[Cocoa] Problem with keyDown

I'm having a problem moving my character in my view using the keyDown method. The problem is that whenever I hold down an arrow key, there's a brief pause after the character moves. It's kind of hard to explain, but my movement looks like this:

It's most likely due to key repeat settings; a key usually doesn't begin to repeat until after a second or so (try holding down a letter key in a textfield to see this). Rather than going by keyDown events, you might want to track both keyDown and keyUp events to determine whether the key is currently pressed; e.g. set a variable to "true" when you receive a keyDown event and "false" when you receive the corresponding keyUp.

your game is itterating based on keydown events, and not polling the key.

so in keydown() you have pos+=1, and keydown gets called once when you hit it, then a pause, then a flood of keydowns occours until you release the key.

you should have, in your keydown, a globalvariable assignment : keys[key] = 0

where : char keys[128];
0 means key is down, and 1 means it is up.

then somewhere else you say if(keys[23]==0)pos+=1.0

--------------------------

advanced : this still isnt the right way. when you are doing nothing, there are no events, when you are mashing on the keyboard, you have like 2000+ events/sec. The game bogs down.....

true keyboard polling is the answer to this problem. I have yet to verify that HID can do true polling. Apple claims it can. The word polling has been confused by HID already, by saying you can "poll the event queue" but that is not true polling.

DirectInput on win32 can do true polling.
linux+xfree86 Can't do it.

If anyone here claims to have a true polling hid example, please post it for us to see!

Even if your program is doing nothing but clearing the window every frame it is hard to imagine any possible way that event handling could take up enough time to bog down your application. Even if you could press 2000+ keys a second (yeah right), I don't think it would cause any change in your framerate.