• Advertisement
Sign in to follow this  

DirectInput KeyboardState with variable keys

This topic is 4825 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 wondering how I would go about checking whether a key has been pressed that has a variable value (allowing custom input keys). I currently have the input working with hard-coded keys but can't quite figure it out for variable values. I could do a loop checking the state of every key and checking if that is my current input key and then actioning but surely there is a better way to do this? This is my current implementataion:
KeyboardState state = deviceKeyboard.GetCurrentKeyboardState();

//What I am currently doing:
if (state[Key.Up])
{
	//Do something...
}

//What I want to do:
if ((state[Key.Up]) || (state[strKeyUp]))
{
	//Do something...
}


This is sort of a repost as I posted this earlier as an addition to another semi-related post but I figure that I'm more likely to get a response as a separate thread. Thanks

Share this post


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

  • Advertisement