Click here to Skip to main content
15,884,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am working on a UWP game engine and am thinking of the best way to find out what keys are pressed at any given moment. I'm considering skipping keyboard events and instead do a check in my gameloop a few times per second. The reason for this is that I want the user to be able to press different combinations of keys, such as two arrow keys to move diagonally while firing a laser gun at the same time. What should I use? My guess is that I should try the Keyboard.IsKeyDown method. Is this a good idea?

Thanks!

What I have tried:

I haven't tried this yet, but am asking anyway as there are usually so many ways to do this.
Posted
Updated 29-Dec-16 22:14pm

1 solution

 
Share this answer
 
Comments
petter2012 30-Dec-16 5:10am    
hi
Well, I've tried this of course and the problem I tried to explain is that there are so many variations, hence my question.
Richard MacCutchan 30-Dec-16 5:54am    
Well the 'best' way is the way that works for your application.
petter2012 30-Dec-16 6:24am    
hi again,
sorry if I was unclear. Most game engine implementations use keyboard events, but I find that conceptually competing with the game loop. Thus , I am curious if it's possible to do if statements checking for different pressed keys and if this is a good approach.

Thanks for your answers so far.
Richard MacCutchan 30-Dec-16 6:28am    
No, the best approach is to use events, since the framework does all the hard work for you.
petter2012 30-Dec-16 6:53am    
ok, thanks!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900