Author Topic: Best way to mimic a keyboard key  (Read 968 times)

paul

  • Newbie
  • *
  • Posts: 16
Best way to mimic a keyboard key
« on: September 07, 2020, 11:21:51 AM »
Hi,

I am disabled and use larger buttons to use key board funtions, so a button that I push goes through an input device which only has four input sockets. these sockets are fixed values, this box has the numbers 1 to 4.

I program voice attack to map the number, i.e '1', to the control in the game, i.e 'space'.

What is the best way to mimic the space key? At the moment I have;

when I push keyboard key '1';
Code: [Select]
    Start Loop While :  Keyboard Key '1 "' Is Pressed
        Press down Space key
    End Loop
    Release Space key

This works but if it's held down for a long time when I release the button it keeps going for a while. I assume as it's had so many loops to do it has to catch up?

Is there a better way to do it?


Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Best way to mimic a keyboard key
« Reply #1 on: September 07, 2020, 11:25:14 AM »
Your command is pressing the space key repeatedly, as fast as possible (spamming it).

To hold down the key, move the press out of the loop, like this:
Code: [Select]
Press down Space key
Start Loop While :  Keyboard Key '1 "' Is Pressed
End Loop
Release Space key

paul

  • Newbie
  • *
  • Posts: 16
Re: Best way to mimic a keyboard key
« Reply #2 on: September 07, 2020, 11:34:14 AM »
Perfect! That makes sense, thanks