Sign in to follow this  
Fallen_Angel

DirectInput KeyboardState with variable keys

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this