1

I want to remap Ctrl - Left to ESC but it does not work. I only can use my right hand and it would be more convenient for me.

Thanks.

I use Arco/linux and kitty terminal.

vim.keymap.set("i", "", "") I thought it should work but it doesn't

1 Answers1

1

I don't know how to remap it only in Neovim off the top of my head, but I can help you remap it system-wide in Linux on an udev level. You can use interception-tools and make a C program to do this. I don't use arco, I use arch linux, but I think it's based on arch, so you can probably just do sudo pacman -S interception-tools and then write this C program or copy and paste if you like, and probably name it better from what I do below

#include <stdio.h>
#include <stdlib.h>
#include <linux/input.h>

int main(void) {
    setbuf(stdin, NULL);
    setbuf(stdout, NULL);

    struct input_event events[2];
    int event_count = 0;

    while (1) {
        if (fread(&events[event_count], sizeof(struct input_event), 1, stdin) != 1) {
            break;
        }

        if (events[event_count].type == EV_KEY) {
            if (events[event_count].code == KEY_RIGHTCTRL) {
                if (events[event_count].value == 1) {
                    event_count++;
                } else if (events[event_count].value == 0 && event_count == 1 && events[0].code == KEY_LEFT) {
                    // Remap Ctrl+Left to Esc
                    events[0].code = KEY_ESC;
                    events[1].code = 0;  // Clear the second event
                    event_count = 0;
                } else {
                    // Not Ctrl+Left, write the events as is
                    for (int i = 0; i <= event_count; i++) {
                        fwrite(&events[i], sizeof(struct input_event), 1, stdout);
                    }
                    event_count = 0;
                }
            } else {
                // Not Ctrl, write the events as is
                for (int i = 0; i <= event_count; i++) {
                    fwrite(&events[i], sizeof(struct input_event), 1, stdout);
                }
                event_count = 0;
            }
        } else {
            // Non-key events, write the events as is
            for (int i = 0; i <= event_count; i++) {
                fwrite(&events[i], sizeof(struct input_event), 1, stdout);
            }
            event_count = 0;
        }
    }

    return 0;
}

You can name this whatever you want but for example I named it right.c.

compile it with gcc -o right right.c and sudo mv right /usr/local/bin, then next make a file with sudo called /etc/udevmon.yaml with these contents

- JOB: intercept -g $DEVNODE | right | uinput -d $DEVNODE
  DEVICE:
    EVENTS:
      EV_KEY: [KEY_RIGHTCTRL, KEY_LEFT]

then you would just sudo systemctl enable --now udevmon.service and it should work. Not sure if you need to reboot or not. If there are any issues please comment and I would love to help further. I'm sorry that you can only use your right arm. :(

Brandon Johnson
  • 172
  • 1
  • 6