Jump to content
  • Advertisement
Sign in to follow this  

[help]Using Keyboard.GetState in a Windows Form Game

This topic is 2264 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm currently trying to make a level editor, using XNA for the graphics, content pipeline and general math and user input.
Input in particular being important as I want the main Control of the form to move around in an FPS view via WASD to move and UDLR to look.
Problem is when I press any of those keys nothing happens, except for when I press left and right and that only fiddles some tabs back and forth.
Do I have to change a focus or something to pick up input with Keyboard.GetState on a specific Control?

if your curious as to how I'm using forms I closely followed the first windows forms XNA sample.

Any and all help is appreciated,
Thanks in advanced,

Share this post

Link to post
Share on other sites
I assume you are polling the keyboard state in an update method somewhere (which is presumably hooked into idle event)?

With Winforms +XNA projects, I've always just fallen back on using the windows event system for input.

Or, if other controls are intercepting the events before your xna control, you could try setting KeyPreview (I think is what its called) on the Form to true.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!