Testing for key pressed

0 favourites
  • 7 posts
From the Asset Store
Random Maze Generator with Door & Key System - tutorial capx
  • There are some similar forum posts out there that have somewhat clarified part of my issue here - I now understand the difference between On Key Down and On Key Pressed. The latter waits for the release of the key.

    MY present issue is that I simply want to have an Action take place when the Event tests that a key has been pressed at all, regardless if the key is held down or released...or not. Just, was it pressed.

    My scenario is that I have a character who will throw a punch upon the K key being pressed. The Action that ought to follow is that the Punch animation will play...from start to finish, all six frames. However, whether I use either On Key Down or On Key Pressed, the animation is immediately interrupted when I let go of the key.

    (I've tried setting up a work-around - and almost got it "perfected" - but it's too lengthy to try to explain.)

    So, ultimately, what I want to happen is this...

    1) I tap the K key and quickly release...

    (SIDE NOTE: Presently, pending a solution, I can hold it down, whether by O.K. Down or O.K. Pressed, and the animation repeats until I release the key.)

    2) ...The punch then plays through a full sequence once regardless of the current true/false of the K key press in subsequent frames.

    I've made sure the Loop is set to No on the animation sequence. I've also tested On Key Released. None of them work for my desired result.

    Thank you for your help!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Could you post .capx or image of the problematic events?

  • What you want is 'on key pressed' but you probably have another event changing the animation when you're not pressing the key.

  • vee41 - *sarcastically to myself* Now why didn't I think of that? *facepalm*

    ramones - Just before I checked the replies here, I was talking it over with my development partner, and that very fact dawned on me. Lo-and-behold, I had another event telling the running animation to reset to an idle pose after the release of - get this - ANY key. *MORE facepalm*

    Thank you BOTH for your prompt replies and willingness to help.

  • Rhindon - i thought i replied to you here haha, here is a capx with hopefully what you want to accomplish:


  • wretchedshark - SIR! I think the missing piece is definitely the On any animation finished. Thank you, once again! :D

    On line 4, I disabled both of the Keyboard S/D is NOT down Events and that didn't seem to have any effect on the outcome of the animations. If I think on it long enough, it'll probably dawn on me - hopefully - but what precisely are those two conditions for in light of the whole project?

  • Rhindon - it's ma'am! :]

    they filter the "on any key pressed" down further to which key is being pressed, i didn't test it with "is down" instead of it. so on s pressed you get the punching animation and on d you get the kicking animation (which in that capx is just a bunch of faces).

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)