Prevent original key from being sent.

Announcements, questions
Post Reply
ParallelMayhem
Posts: 1
Joined: 06 May 2020, 12:50

Prevent original key from being sent.

Post by ParallelMayhem » 06 May 2020, 12:54

Hi,
I'm currently messing around with the quickstart script and and I can't seem to stop the original key I press from showing up.
This is my code:

Code: Select all

clear() --clear the console from last run
local keyboardIdentifier = 'ID_02A1'
lmc_device_set_name('MACROS1', keyboardIdentifier);

-- define callback for whole device, assign each key of the keyboard to an imaginary key (usually, keyboards have F1-F12, so we start assigning keys to F13)
lmc_set_handler('MACROS1',function(button, direction)
  if (direction == 1) then return end  -- ignore down; if you want to be able to type the original letters as well with the secondary keyboard, remove this line
     if     (button == string.byte('S')) then lmc_send_keys('^s')
     elseif (button == string.byte('F')) then lmc_send_keys('{y}')
     elseif (button == string.byte('A')) then lmc_spawn("C:\\Program Files\\Blender Foundation\\Blender 2.82\\blender.exe")
     elseif (button == string.byte('2')) then lmc_send_keys('{F15}')
     elseif (button == string.byte('3')) then lmc_send_keys('{F16}')
     elseif (button == string.byte('4')) then lmc_send_keys('{F24}')
     elseif (button == 90) then lmc_send_keys('^+%{b}') -- once F keys are over, just use combitations with alt, ctrl, shift, win, or tab (https://github.com/me2d13/luamacros/wiki/List-of-Keys)
     -- etc.
     else print('Not yet assigned: ' .. button)
  end
end)
When I press 'F' on my second keyboard, I want it only only output 'Y' instead of 'fY'
Backspacing won't do in my case because I want this to work as hotkeys in my progams.
Any idea how to achieve this?

Post Reply