Author Topic: Record key pressed as a variable.  (Read 1511 times)

Absurdius_Maximus

  • Newbie
  • *
  • Posts: 2
Record key pressed as a variable.
« on: February 13, 2022, 03:13:06 PM »
Ahoy,

I have a decent bit of experience with this now but one thing throws me off, unsure if it can be done. Is there a way for VA to record the current key pressed as a variable?
I am trying to add a "Hold this for me" like command where, for example, "W" key is pressed and VA records it and keeps it pressed allowing me to let go. VA keeps it pressed until I return and press "W" again or the mythical "Any Key" key? I've gone through a lot of the settings but not sure how to go about this, if it's possible.

Any help is appreciated!
Thanks in advance.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Record key pressed as a variable.
« Reply #1 on: February 13, 2022, 03:37:40 PM »
There is currently no method for retrieving arbitrary pressed keys, no. A feature suggestion for this has been made.


You'd need to check all keys you anticipate wanting to hold down individually, E.G. by setting up a condition for each one.

Something that may also work is to use the "Block Keyboard Input" action to block all keys momentarily, which can prevent the release of a key from getting through to a target application.
E.G. you could block all keys while you're only holding down the key you want to be held down (which should logically be the case anyway, as per your original intent), have a pause in the command so you have enough time to physically release the key, and when the pause has elapsed unblock all keys again.

Absurdius_Maximus

  • Newbie
  • *
  • Posts: 2
Re: Record key pressed as a variable.
« Reply #2 on: February 15, 2022, 11:02:21 AM »
Ah, I didn't think that was possible. Thought it'd check anyways. I have tried blocking keyboard input but I've found that to be a hassle as it's caused more issues to work. I am just going to set up a small conditional with the few keys I need held on occasion.

Thanks for the reply!