input-remapper icon indicating copy to clipboard operation
input-remapper copied to clipboard

How to map key combo without disabling individual keys

Open PatrickNotStar23 opened this issue 8 months ago • 4 comments

Is it possible to map a key combo without disabling the individual keys making up the combo? I want to map BTN_LEFT + BTN_RIGHT to BTN_MIDDLE, but retain BTN_LEFT and BTN_RIGHT functionality when they are pressed individually. When I try to apply it in the GUI it says "this would disable your click button"

PatrickNotStar23 avatar Apr 18 '25 22:04 PatrickNotStar23

I have no idea whether your assignment is basically possible, but it would be helpful for me if you could upload a screenshot of the GUI in which you tried to realize this constellation

When I try to apply it in the GUI

and got this error message

this would disable your click button

So that it is clear which values you are using in “Input” and “Output” and I can reliably reproduce your desired assignment.

HappyPony avatar Apr 20 '25 07:04 HappyPony

I'm basically trying to implement KensingtonWorks "chording" feature for my trackball where I can press pairs of buttons to act as another button. Obviously this current mapping doesn't work, it would probably need to be a config rather than GUI. Something like if each button is pressed within 50ms of eachother they act as the chorded button, otherwise they pass their regular assigned buttons. (ignore the control L shift L, it should be middle click) Image Im actually able to implement the left + right click = middle click using libinput's middle button emulation, however I'd still like to assign keys to both top buttons, both left buttons, both right buttons etc.

PatrickNotStar23 avatar Apr 20 '25 22:04 PatrickNotStar23

Thank you for the clarification. I have only recently been introduced to “Input Remapper” and am impressed with the possibilities this program offers to increase my productivity at work and improve comfort at the client.

Simultaneous keystrokes are not currently part of my typing routine. I have purchased a Razer Tartarus Pro keyboard to save time when making certain entries - also with “Input Remapper”

I submitted your question to the language model https://chat.mistral.ai/ and got this answer. Here is the short version:

In Input Remapper, it's not possible to map a key combination without disabling the individual keys that make up the combination. This is because the program is designed to require a unique assignment for each key or key combination to avoid conflicts. However, if you want to implement a "chording" feature where pressing two buttons simultaneously triggers a third action, while retaining the original functionality of the individual buttons, you may need to use advanced configurations or scripts.

Example of a Python script with evdev Here is a basic example of how to implement chording with a Python script using evdev:

code begin

from evdev import InputDevice, categorize, ecodes, list_devices from select import select import time

#Find your device devices = [InputDevice(path) for path in list_devices()] for device in devices: print(device.path, device.name, device.phys)

#Replace with your device path device = InputDevice('/dev/input/eventX')

#Timing threshold for chording threshold = 0.05 # 50 ms

#Track button states and timestamps button_states = {ecodes.BTN_LEFT: (False, 0), ecodes.BTN_RIGHT: (False, 0)}

def is_chorded(button1, button2): state1, time1 = button_states[button1] state2, time2 = button_states[button2] return state1 and state2 and abs(time1 - time2) <= threshold

print("Listening for events...") while True: r, w, x = select([device.fd], [], []) for event in device.read(): if event.type == ecodes.EV_KEY: key_event = categorize(event) if key_event.scancode in button_states: button_states[key_event.scancode] = (key_event.keystate == key_event.key_down, time.time()) if is_chorded(ecodes.BTN_LEFT, ecodes.BTN_RIGHT): print("Chord detected: BTN_LEFT + BTN_RIGHT") # Perform middle click action here # Reset state if button is released if key_event.keystate == key_event.key_up: button_states[key_event.scancode] = (False, 0)

code end

I'm uploading the script generated by chat.mistral.ai here. So that the CO2 emissions I caused with my question to the mistral.ai language model were not in vain ;-). Maybe other users can reuse it somehow.

Attached is the complete mistral.ai answer map-key-combo-Akkord-mistral-ai-answer-1096.pdf. Thanks again for clarifying the description. I can imagine that in future - if the “Input Remapper” functionality is not enough for me - I will fall back on the libinput functionality.

HappyPony avatar Apr 21 '25 08:04 HappyPony

I'm basically trying to implement KensingtonWorks "chording" feature for my trackball where I can press pairs of buttons to act as another button.

You should just set middle click emulation by issuing gsettings set org.gnome.desktop.peripherals.trackball middle-click-emulation true in a terminal.

Edit: just read below the image that you want to achieve a more complex mapping. I've been able to enable middle-click by using left-click + right-click using input-remapper until I found out that trackballs required the command above (I was thinking that peripherals.mouse would works for them too), but it would not work reliably, as the time window to activate both buttons was too short. Most o the time it would just register a left-click followed by a right-click, or the other way around.

cgraeff avatar Apr 22 '25 12:04 cgraeff