Author Topic: Key Press/Programming Question  (Read 658 times)

MaxSharp

  • Newbie
  • *
  • Posts: 3
Key Press/Programming Question
« on: April 19, 2017, 06:41:16 pm »
Good evening,

I'm a bit confused on how to correct this...

When I select keypress in order to bind two keys for a particular voice command, the key press function only allows me to bind two keys utilizing the 'Shift, Control, Windows and Alt' key along with one other regular key (such as w, s, d, etc)....

Is there a way to simply select two basic keys (such as w+s, x+a, c+d)???

In advance, thank you for the help!

~MaxSharp

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1099
  • RTFM
Re: Key Press/Programming Question
« Reply #1 on: April 20, 2017, 04:25:37 am »
the key press function only allows me to bind two keys utilizing the 'Shift, Control, Windows and Alt' key along with one other regular key
Those particular keys are modifiers, I.E. they exist to be combined with another key and don't usually serve a function by themselves in a normal application environment(video games are the exception to that, but computers were not initially designed with those in mind), which is why those are the ones you can combine with others.

If you're looking to press down and release multiple keys near-simultaneously and send them to an application, you can use separate press, pause, and release actions:
Code: [Select]
Press down W key
Press down S key
Pause 0,01 seconds
Release W key
Release S key


If instead you need to trigger a command using multiple non-modifier keys, you could set the first key as the actual trigger, then follow that up within the command to check if the others are held down:
Code: [Select]
Begin Text Compare : [{STATE_KEYSTATE:S}] Equals '1'
End Condition - Exit when condition not met
If you press the key almost exactly at the same time(with little margin), those actions will allow the command to run; Otherwise, they stop it before anything else can execute.

There are other ways to accomplish this as well(multiple commands triggered by the individual keys, or loops to check states), but if you're looking to make regular use of such a mechanic, you could put in a feature request for it.

MaxSharp

  • Newbie
  • *
  • Posts: 3
Re: Key Press/Programming Question
« Reply #2 on: April 20, 2017, 06:18:34 am »
This is very helpful information--thank you!

In regards to the relayed 'code', where exactly do I place it? Under the key press data box?

Thank you

~MaxSharp

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1099
  • RTFM
Re: Key Press/Programming Question
« Reply #3 on: April 20, 2017, 11:53:04 am »
In regards to the relayed 'code', where exactly do I place it?
Depends on which example, but both are the same text you'd see in the action list, intended as a guideline for which actions you can recreate within your commands.

The first example contains:
  • A Keypress action for "W", set to the "Press Key(s)" option
  • A Keypress action for "S", set to the "Press Key(s)" option
  • A Pause action set to 000.010 seconds
  • A Keypress action for "W", set to the "Release Key(s)" option
  • A Keypress action for "S", set to the "Release Key(s)" option

The second example contains:
  • A "Begin a Conditional (If Statement) Block" action, using the "Text" tab's "Variable name" field set to "{STATE_KEYSTATE:S}", the dropdown set to "Equals", and the "Text" field set to "1"
  • A "End a Conditional Block" action with the "When this block is reached, exit command if condition is NOT met" option checked

MaxSharp

  • Newbie
  • *
  • Posts: 3
Re: Key Press/Programming Question
« Reply #4 on: April 20, 2017, 05:34:07 pm »
Thank you very much for the quick response--much appreciated!

~MaxSharp