Author Topic: Making it simple to have a key hold till release in VA  (Read 2671 times)

iceblast

  • Sr. Member
  • ****
  • Posts: 372
Making it simple to have a key hold till release in VA
« on: October 04, 2018, 10:29:39 AM »
I've been meaning to bring this up for awhile, except I would forget about it every time I came to the forums. :)

I would imagine it's a pretty common issue for people to want to make a command that presses a key, and they want it to act like the keyboard does. So, if you press 4, and hold it to charge an attack, it will hold the 4 key down till you release.

I understand this can be done with a loop command...

Code: [Select]
Start Loop While :  Keyboard Key '4 $' Is Pressed
Press down 4 key
End Loop
Release 4 key

but that just seems like a lot of extra work, and it's not really simple for most people to understand how to do.

How about adding a check box for the command key to press and hold till release. Making that loop internal to VA. I can't be the only one that finds it odd that this is missing. Unless of course, there is a good reason already why it hasn't been added.


Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4760
  • RTFM
Re: Making it simple to have a key hold till release in VA
« Reply #1 on: October 04, 2018, 01:50:17 PM »
Code: [Select]
Start Loop While :  Keyboard Key '4 $' Is Pressed
Press down 4 key
End Loop
Release 4 key

How is this intended to work? As written currently, if the key isn't already down, the loop will never run; If the key is already down, there's no need to press it again(let alone repeatedly in a loop).

iceblast

  • Sr. Member
  • ****
  • Posts: 372
Re: Making it simple to have a key hold till release in VA
« Reply #2 on: October 04, 2018, 02:55:12 PM »
Sorry, I suck at explaining things. I'm long winded.

Let's say, you're playing a game, and you want to remap a key. 4 key is now the F14 key.

You a make a command.

Press F14

Code: [Select]
Press 4 key and hold for 0.06 seconds and release

Now when you hit F14, it will press and release the 4 key one time.

But in the game, if you hold the 4 key, you will charge up your attack till you release the 4 key. You no longer have this ability with this command.

In order to bring back that ability, you have to create a Loop.

Code: [Select]
Start Loop While :  Keyboard Key 'F14' Is Pressed
Press down 4 key
End Loop
Release 4 key

OR

Code: [Select]
Start Loop While : [{STATE_KEYSTATE:F14}] Equals '1'
Press down 4 key
End Loop
Release 4 key

Now, when you hold F14, your attack will charge up, and when you release F14, you'll attack.

I've run into the need to make a loop key command many times in games. Any hold and release command in a game would require it. To my knowledge, there is no simple way to do this in VA, you have to make a loop command.

What I'm asking is, why not make that loop internal to VA, when you check a box or something. I think a command like this should be a common option. Because it can be confusing to people who don't know that much about VA commands, and it would save some time, for when you have to setup a bunch of these.



Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4760
  • RTFM
Re: Making it simple to have a key hold till release in VA
« Reply #3 on: October 04, 2018, 03:23:21 PM »
Unless you want to make sure the key stays pressed even if the physical key is, there's no need to send the press inside the loop, you can just do it once:
Code: [Select]
Press down 4 key
Start Loop While :  Keyboard Key 'F14' Is Pressed
End Loop
Release 4 key


As for turning this into a checkbox, can you outline how that would work in practice?

Commands execute from top to bottom, they don't have a "when command starts" and "when command ends" section, so how would you execute the press and release separately?



If you're permanently replacing a key, you can also use the "Shortcut is invoked only when all keys are released" option in a second command and have that trigger the release.

E.G.
When I press keys : F14
Code: [Select]
Press down 4 key
When I press keys : F14 (with "Shortcut is invoked only when all keys are released" checked)
Code: [Select]
Release 4 key

iceblast

  • Sr. Member
  • ****
  • Posts: 372
Re: Making it simple to have a key hold till release in VA
« Reply #4 on: October 04, 2018, 09:54:56 PM »
Yeah, the 2 command thing works well also, never thought of that. How about Integrating that trick then.

How about a check box in "When I press keys:"

That when you release the key F14, it's only job would be to release all keys in that command.

And under "Key Press"

Press down 4 key

So it would be similar to "Shortcut is invoked only when all keys are released" but instead it would just Release all keys. in that command, when all keys are released.

"Shortcut is Deactivated only when all keys are released" (For Hold and Release Actions)

Examples, to cook a Grenade, to power up an Attack, to press a Gas Petal. Actions that require you to hold a key down continuously for them to work, and only stop when you release that key.

Many games make use of actions like these. Would be cool if VA could use them, in a simpler to implement way.