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

key-remap configuration to remap modifiers at the app-level #5160

Open
mitchellh opened this issue Jan 16, 2025 · 4 comments
Open

key-remap configuration to remap modifiers at the app-level #5160

mitchellh opened this issue Jan 16, 2025 · 4 comments
Labels

Comments

@mitchellh
Copy link
Contributor

mitchellh commented Jan 16, 2025

Discussion: #3493 (comment)

Introduce a new configuration key-remap which can be used to remap keys from one to another within the scope of Ghostty. Example:

key-remap = ctrl=super
key-remap = left_control=right_alt

This would act the same as if a user went to their OS config and remapped these keys. If a sided-modifier isn't specified, then left swaps with left, right swaps with right.

Notes:

  • This is a one way remap. In the example above, ctrl becomes super but super does not become ctrl.
  • Remaps are not transitive. If you remap ctrl=super and then alt=ctrl, then alt != super. Alt would be mapped to control.
  • This doesn't interact with keybind in any way. In the same way keybind is already roughly unaware of keyboard layouts (i.e. cmd+f works with f as specified by your layout), the same will happen in this case (i.e. cmd+f will trigger with a physical "ctrl" key if you remapped cmd=ctrl).

Additional scope limiting

For the initial creation of this feature, we should limit scope in the following ways:

  1. Only remap modifier keys
  2. Only work on macOS

There is a much more urgent need and request for this on macOS (see #3493) and macOS APIs give us a much easier way to do this by easily letting us insert event filters in the path. My attempts at doing this with GTK have thus far failed, but I think it's possible.

In the future, we can likely lift both of these limitations.

@mitchellh
Copy link
Contributor Author

mitchellh commented Jan 16, 2025

Just repeating myself: this is only tagged macOS because I'm happy to close this one macOS supports this. This has been heavily requested by macOS users and the discussion explains many reasons why. I don't recall seeing any requests for this at all for Linux users but if there are it's been relatively few.

The design of the config does not preclude Linux support in the future.

@chenzhiwei
Copy link

Hi, could you include this feature in 1.2.0 milestone?

@00-kat
Copy link
Contributor

00-kat commented Feb 20, 2025

is this not the same as #4335?

@jwalton
Copy link

jwalton commented Feb 20, 2025

@00-kat #4335 is about using a modier key by itself to kick off an action (like double tapping ctrl to open a new terminal). This is about remapping the modifier keys themselves (e.g. making it so when I hit CTRL-C it behaves as if I'd hit CMD-C, and when I hit CMD-C it behaves as if I'd hit CTRL-C).

#3493 talks about the motivation in detail but briefly: a lot of Mac users (especially ones who come from Windows or Linux) swap the CTRL and CMD keys in the OS, so that CTRL-C is copy and CTRL-S is save and everything works the way they're used to it working on other platforms. On other platforms, in a terminal though, CTRL-C is still "break", so you want CTRL and CMD swapped in all apps, except in your terminal program. The easiest way to do that is "swap them back" in the terminal. iterm2 makes this really easy, but ghostty sadly does not.

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

No branches or pull requests

4 participants