I\'ve begun writing a game using XNA Framework and have hit some simple problem I do not know how to solve correctly.
I\'m displaying a menu using Texture2D and using th
If your application is for a Windows machine, I've had great success using this event driven class that I found here: gamedev.net forum post
It handles typical key presses and the short pauses before the repeating starts, just like normal text entry in a Windows application. Also included is mouse move/wheel events.
You can subscribe to the events, for example, using the following code:
InputSystem.KeyDown += new KeyEventHandler(KeyDownFunction);
InputSystem.KeyUp += new KeyEventHandler(KeyUpFunction);
Then in the methods themselves:
void KeyDownFunction(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.F)
facepalm();
}
void KeyUpFunction(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.F)
release();
}
...and so forth. It really is a great class. I've found it's flexibility much improved over XNA's default keyboard handling. Good Luck!