Simulate Keyboard pressing

0 favourites
  • 7 posts
From the Asset Store
Basketball Practice is HTML5 game written in construct 2 and 3 engine that simulates hooping.
  • Hi everyone!

    I was wondering if there was a way to simulate a keypress action.

    For exemple :

    Gamepad button A down --> Simulate X key down

    Gamepad button A pressed --> Simulate X key pressed

    Gamepad button A released --> Simulate X key released

    But it seems there's no keyboard action available.

    That would be so more easy for me to add a gamepad support this way. :)

    Perhaps you know a method to do this.

    Thank you.

  • KaMiZoTo

    At the moment I can only think of one way to do it, but it's extremely tedious and rather dodgy. But if you still want to try it, here's what I am thinking.

    Make global variable for all your control keys 'X', 'Y', etc. Make it a number variable or a text value, it's up to you (text would be easier but more tedious to type).

    Set up your events so it's like if gamepad button A pressed set 'X' (the global variable) to "pressed", and then copy it and invert it and make it set 'X' to "released". This means that when Gamepad button A is not pressed it sets 'X' to "released".

    This can be applied for the other actions too.

    Then, make an event:

    If 'X' = "released" --> (Your actions, don't shoot for example)

    If 'X' = "pressed" --> (Your actions, Shoot for example)

    That's a very clunky work around, but it should do it's job (I'm away from my PC so I can't really check).

  • Thank you lonehangman for your answer!

    Yeah I though about that solution too. But as you said, it's quite tedious.

    But if it's the only way to do it, I will have to. :*(

  • Take a look at XPADDER

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • XPADDER seems to be a Windows software. And I supposed it has to be installed by the player in order to use the pad functions. I prefer to not use external tools to be sure everything works on any system (on Mac for example).

    Am I wrong ?

    But thank you for the link. :)

  • I'm kinda wondering why you want to simulate keypresses when you could just copy your keyboard events and switch out the conditions with the gamepad equivalents. Or if your control scheme isn't overly complicated just have the gamepad and keyboard input events together in "OR" blocks.

    I also imagine being able to simulate keypresses would be a big security issue with browsers, and would not expect it to be possible.

  • Thank you inkBot!

    I haven't though about the "OR" blocks! Now that I almost know how the sub event can be used with this "OR" function, it should definitly work. :)

    Sorry if my question seems stange. I'm still learning how to do so basic things. ^^

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