Ignore combined keys

Announcements, questions
Post Reply
aSa
Posts: 3
Joined: 11 May 2020, 15:16

Ignore combined keys

Post by aSa » 11 May 2020, 15:35

Hello,
I use an external programmable keyboard (a keypad with QMK firmware) which allows me to get several layers with a few keys.

Is there a simple way to have all single keys intercepted by LuaMacros, and all the key combinations ignored?

For example, I program my keypad to send "F4" with the 1st key and "CTRL + F4" with the 2nd key.

I would like LuaMacros
to interpret only the "F4" alone to launch a software
and ignore the “CTRL- F4” which should be transmitted as is to the system

If I set a trigger for the whole keyboard, all the keys are blocked by LuaMacro and I am therefore obliged to code again all the key combinations to get them repeated.

I managed to know the CTRL key status with a variable that I set depending on whether the key is pressed or released

Code: Select all

lmc_set_handler('KeypadQMK',function(button, direction)

    if (button == 17 and direction == 1) then -- CTRL DOWN
        QctrlFlag = true
    end
    if (button == 17 and direction == 0) then -- CTRL UP
        QctrlFlag = false
    end

        if (direction == 1) then return end  -- ignore down

        if (button == 115 and QctrlFlag == false) then 
            -- F4 detected
            lmc_spawn("calc")
            
        elseif (button == 115 and QctrlFlag == true) then 
            -- CTRL + F4 detected
            lmc_send_keys('^{F4}')

        else
            print('not  yet assigned: ' .. button)
        end
end) 

It works but since I have a lot of keys which are CTRL, SHIFT, ALT, or Window key combinations, I would like to avoid having to redefine them one by one.

Something like this would be perfect :

Code: Select all

    if (direction == 1) then return end  -- ignore down
    if (QctrlFlag == true or QaltFlag == true or QshiftFlag == true or QwinFlag == true) then 
        -- leave it as is and pass it to the computer
     else 
            if (button == 115) then  lmc_spawn("aaa")
            if (button == 116) then  lmc_spawn("bbb")
            if (button == 117) then  lmc_spawn("ccc")
    end
Thank you for any help et please, excuse my bad english

admin
Site Admin
Posts: 735
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: Ignore combined keys

Post by admin » 12 May 2020, 07:50

This can't be done. The callback can be attached to whole keyboard or to single key. But modifiers (alt, ctrl) do not play a role as they are considered as key themselves. And also luamacros main idea is to have multiple keyboards so you can do actions with single key - to avoid using complex modifiers (ctrl+alt+something)
Petr Medek
LUAmacros author

aSa
Posts: 3
Joined: 11 May 2020, 15:16

Re: Ignore combined keys

Post by aSa » 12 May 2020, 08:17

Unfortunately, that's what I understood : I have to explicitly code each key combination.

Thank you for your answer and for this software

aSa
Posts: 3
Joined: 11 May 2020, 15:16

Re: Ignore combined keys

Post by aSa » 13 May 2020, 10:04

If someone has a similar need to mine, i.e. just a numeric keypad with several layers to send key combinations, open predefined folders or launch programs;
I finally found Clavier+
http://utilfr42.free.fr/util/ClavierDoc.php#utility

This software is small, portable, easy to configure, and - with a 2 days experience - perfectly running.

Unlike LuaMacros, it is not able to recognize different keyboards, so you have to use a programmable numpad with key combinations that are never used (Example CTRL + ALT + WIN + F1) to avoid confusion with the main keyboard

Post Reply