Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommended way to disable a key sequence? #297

Open
hab25 opened this issue May 27, 2023 · 3 comments
Open

Recommended way to disable a key sequence? #297

hab25 opened this issue May 27, 2023 · 3 comments

Comments

@hab25
Copy link

hab25 commented May 27, 2023

It's probably worth mentioning the answer to this question in the README.

Note:
I'm currently achieving this by using the reserved key.
The use case is to learn a new keymap faster when the key you want to disable should not be used for anything. For example:


I want to start using C-l to close a google chrome tab, I don't want to use use C-w for anything, and currently, I'm using C-w to close a google chrome tab (this a google chrome default and cannot be disabled). I can do

{
  "keymap": [
    {
      "application": {
        "only": "Google-chrome"
      },
      "exact_match": true,
      "remap": {
        "c-w": "reserved",
        "c-l": "c-w"
      }
    }
  ]
}

This way, C-w will start not doing anything which will help me break the habit of using it to close tabs.


Q: Why not use two keybinds to do the same thing?
A: Spreading your habit among multiple keybinds weakens the muscle memory for any single keybind. Further, it makes the event that one of the keybinds is changed into some other command in the future easier to learn. More abstractly, one thing is generally simpler than multiple.

@hab25 hab25 changed the title Recommended way to disable a key sequence (make it send no key press)? Recommended way to disable a key sequence? May 27, 2023
@k0kubun
Copy link
Contributor

k0kubun commented May 28, 2023

Nice tip. It might be too much for many users to see the entire context of this in README, but I think it's nice to mention reserved can be used for disabling a key and briefly explain why it could be useful. Would you be open to writing a pull request to make that change on README?

@hab25
Copy link
Author

hab25 commented May 28, 2023

Would you be open to writing a pull request to make that change on README?

Yes, after we reach an agreement here.

One concern: reserved is not a no-op; applications could interpret it, and so it could have undesirable effects:


As per this comment in the Linux kernel repo,

Most of the keys/buttons are modeled after USB HUT 1.12 (see http://www.usb.org/developers/hidpage)

From https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf:

Reserved (no event indicated)⁹

⁹ Reserved for typical keyboard status of keyboard errors. Sent as a member of the keyboard array. Not a physical key.


So, wouldn't it be better if xremap implemented being able to specify null (which exists in JSON and (therefore) also in YAML 1.2) as the no-op, i.e. such that it can be used in place of how I'm currently using reserved?

I'm don't know and can only guess how xremap, evdev and uniput work, but by "no-op" I mean something like:

Intercepting from evdev the key event which was mapped to null, sending nothing to uinput.

@k0kubun
Copy link
Contributor

k0kubun commented Jun 8, 2023

That makes sense. I'd be open to merging a pull request that implements the null feature. In the meantime, using reserved could be a quick alternative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants