kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
24.62k stars 986 forks source link

Improve keyboard layout handling #2000

Closed bew closed 3 years ago

bew commented 5 years ago

This issue will track progress and discussion to improve keyboard layout handling. (continuing the discussion started in https://github.com/kovidgoyal/kitty/issues/1980)

TL;DR: #1990 & #1980 should work out of the box.

What

Make 'composed' shortcut work with any modifiers (need to rephrase?) With the french keyboard layout, typing shift+: should send / to the terminal app, and alt+shift+: should send ^[/. The former already works, but the latter does not send anything (this is the problem description of #1980). Same problem with https://github.com/kovidgoyal/kitty/issues/1980#issuecomment-532898630 (alt+altgr+" should give alt+#).

Handle non-standard modifiers from keyboard layouts Given some_mod+X with some_mod a non standard mod like ISO_Level2_Shift. Currently when X is a key that exist directly in the US layout, the resulting key is the shifted version of the matching US layout key (was done because of https://github.com/kovidgoyal/kitty/issues/171#issuecomment-372032258). This would also fix #1990. → Correct layout handling should fix this automatically

Allow kitty shortcut using resolved keys and real pressed keys To make map alt+shift+: ... work the same as map alt+/ ... → This will be easy once we make GLFW report both on a key event!

Idea - keyboard layout agnostic Kitty shortcut It would be nice to have layout-independent kitty-shortcut, using a special syntax like map @ctrl+shift+c ... (we're back to #606..), so that you can switch between (e.g) French and Russian and still be able to use these Kitty shortcuts. (or map! ctrl+shift+c ... to avoid any key clash and give a kind of semantic "it should always work!!")

Existing behaviors to keep

How

  1. Extract glfw key event to a struct, to make futur changes easier (#1998)
  2. Experiment with xkbcommon :hammer_and_wrench: The idea is to check with xkbcommon the modifiers consumed by the resulting key (ex: shift for shift+:)

I'll update this post when I find other things!

Luflosi commented 5 years ago

Actually the Russian keyboard layout should work, I'm pretty sure I added all the keys for it. Other than that, this looks promising.

bew commented 5 years ago

Actually the Russian keyboard layout should work

Oh right, then for other people with weird symbols :smiley:

Either way, it would be nice to be able to make kitty-shortcut that are layout independent, using a special syntax like map @ctrl+shift+c ... (we're back to #606..), so that you can switch between french and russian and still be able to use these Kitty shortcuts! I'll add it above

(or map! ctrl+shift+c ... to avoid any key clash and give a kind of semantic "it should always work!!")

Panke commented 4 years ago

Is there any progress on this? I have the same issues with the neo layout.

maksbotan commented 4 years ago

Re Russian layout. Some time ago after Kitty update I've noticed a problem: no shortcuts work when Russian layour is selected. For example, I've used to be able to press Ctrl-C or Ctrl-w on any layout, but now it works only on US layout. This is very annoying.

Can it be reverted until you find a proper solution? Because it worked before.

BTW, strangely, I started to experience the same problem on macOS recently.

bew commented 4 years ago

Is there any progress on this? I have the same issues with the neo layout.

Hi, sorry didn't see your message. I don't have much time for personal projects currently, so no, no progress on this. Also as I'm (unfortunately) forced to use windows at work (and have some of the same problems, but it's another topic ^^) I don't really use kitty at the moment.

maksbotan commented 4 years ago

@kovidgoyal hi, can you also please respond to my problem above (https://github.com/kovidgoyal/kitty/issues/2000#issuecomment-623150900)?

kovidgoyal commented 4 years ago

Use debug keyboard to see what keys w and c are in your layout and map them using send_textto send the bytes corresponding to ctrl_w and ctrl+c

maksbotan commented 4 years ago

Well, this is rather clumsy, given that it used to work. Could you revert the change that broke it?

kovidgoyal commented 4 years ago

This has already been discussed elsewhere, read up on it, or if you dont have the time, just implement the workaround.

Luflosi commented 4 years ago

Here is the issue where this has been discussed: #606. I think some of the comments towards the bottom might be what you're looking for but I would recommend reading the entire issue.

maksbotan commented 4 years ago

@Luflosi thanks! Somehow I missed #606 while reading this thread. Sorry!

I'll hope that this issue will be eventually resolved.

maksbotan commented 4 years ago

So for anyone finding this issue in the future, here are bindings for most basic keys (^C, ^D, ^H, ^W):

map ctrl+CYRILLIC_ES send_text all \x03
map ctrl+CYRILLIC_VE send_text all \x04
map ctrl+CYRILLIC_ER send_text all \x08
map ctrl+CYRILLIC_TSE send_text all \x17

This will make them "work" on Russian layout the same way as they do on English.

nikto-b commented 4 years ago

Not sure that is that, but I have some troubles with handling keyboard using Russian language in sway Have no idea about the cause, but it exists zsh 5.8 (x86_64-pc-linux-gnu) One Two Three

kovidgoyal commented 3 years ago

This should be fixed in master, though I have not tested it much given I only have standard pc keyboards.

Jakeroid commented 9 months ago

Here is mine solution. Actually, the idea is the same to map each shortcut for the non-Latin character, but I made automated script to do that.

https://jakeroid.com/blog/kitty-shortcuts-work-only-with-latin-characters-how-to-fix