HOWTO: Input Keystrokes with Modifiers (Shift,Ctrl,Alt)

florian

2016-02-03 14:01:29

Hi,
in version 1.8 of MIDI Translator Pro, you can use single keys as trigger for Incoming Actions, but it is not straight forward for keyboard shortcuts like Ctrl+S (as it is possible in the keystroke Outgoing Action). We will work on this for a future version of MT, but for now, you can use this recipe:

For all the needed modifiers, define separate incoming actions, which each set a global variable to 1 if the respective modifier is down, and reset it to 0 if up. I use the global variables starting with "m", and second letter s for Shift, c for Control, and a for Alt:

Code: Select all

[x] Translator 0.0: Shift down
Incoming: Key down: Shift
Rules: ms=1
Outgoing: (none)

[x] Translator 0.1: Shift up
Incoming: Key up: Shift
Rules: ms=0
Outgoing: (none)

[x] Translator 0.2: Ctrl down
Incoming: Key down: Ctrl
Rules: mc=1
Outgoing: (none)

[x] Translator 0.3: Ctrl up
Incoming: Key up: Ctrl
Rules: mc=0
Outgoing: (none)

[x] Translator 0.4: Alt down
Incoming: Key down: Alt
Rules: ma=1
Outgoing: (none)

[x] Translator 0.5: Alt up
Incoming: Key up: Alt
Rules: ma=0
Outgoing: (none)
Now for the actual keys you want to do an action in response to, use the Rules to check for the modifiers. Here are a few examples, where the Translator name tells you which keystroke combination it is triggering on, and sends a MIDI Control Change when the respective shortcut is pressed:

Code: Select all

[x] Translator 0.6: Ctrl+S
Incoming: Key down: S
Rules:
  if ms!=0 then exit rules, skip Outgoing Action
  if mc!=1 then exit rules, skip Outgoing Action
  if ma!=0 then exit rules, skip Outgoing Action
Outgoing: Control Change on channel 1 with CC#:60 (0x3C) and value:65 (0x41)

[x] Translator 0.7: Shift+Ctrl+Alt+A
Incoming: Key down: A
Rules:
  if ms!=1 then exit rules, skip Outgoing Action
  if mc!=1 then exit rules, skip Outgoing Action
  if ma!=1 then exit rules, skip Outgoing Action
Outgoing: Control Change on channel 1 with CC#:60 (0x3C) and value:63 (0x3F)
Attached is the demo project.

Hope that helps!
Florian
Attachments
Keystroke Input with Modifiers.bmtp
(1.82 KiB) Downloaded 242 times