Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a game where I need to perform an action by pressing U and K at the same time, but I also want it to be accomplished by only using one key, because pressing both at the same time ties up your hand a bit.

How would I accomplish this?

share|improve this question

closed as not a real question by Nicol Bolas, msell, Sean Middleditch, Laurent Couvidou, Trevor Powell Jun 19 '13 at 9:34

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Maybe you can walk us through the steps on what you want? It's not really clear to me at least. The player needs to press U and K? What does "using one key to input the animation" mean? – Byte56 Jun 15 '13 at 0:10
I need to press U and K at the same time to basically. U = block, K = power, but if you press both at the same time and hold them, then you do a power block in the game. It ties up your hands a bit, so I want to just press one key to function like U+K. I want to be able to use something like "O" and it function like I pressed U and K. – DWOplayer Jun 15 '13 at 1:19

This is pretty simple. Basically, you just have another key call the same function as U+K does.

if((keyDown('U') && keyDown('K')) || keyDown('O'))

Basically that's saying if the U key AND the K key are pressed, OR the O key, do the action. Or depending on how you have things arranged, you could do something like:



if((keyDown('O')) {
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.