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

Ability to disable some dead keys #5784

Closed
gpotter2 opened this issue May 7, 2020 · 14 comments · Fixed by #7686
Closed

Ability to disable some dead keys #5784

gpotter2 opened this issue May 7, 2020 · 14 comments · Fixed by #7686
Labels
Area-Input Related to input processing (key presses, mouse, etc.) Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Help Wanted We encourage anyone to jump in on these. Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.

Comments

@gpotter2
Copy link

gpotter2 commented May 7, 2020

Description of the new feature/enhancement

Feature: Ability to disable SOME dead keys.

Motivation

It might be hard to understand for people who have sensible layouts, but many keyboard layouts have dead keys that are very cumbersome when programming.

I personally use the terminal on the daily, and the tilde ~ is used a lot in Linux. On my AZERTY default layout, ~ acts as a dead key: i need to type it then add a space to get a single ~. See the layout below
image
~ needs ALTGR + 2 + space. This is exhausting. We also have a dead ^ that could use this feature.

Notes

  • Ubuntu provides very useful layouts made for coders, that disable the cumbersome dead keys: https://askubuntu.com/questions/56560/what-exactly-is-meant-by-eliminate-dead-keys . Windows doesn't provide this natively, thus this feature request (I would never expect this to be added to the main OS...)
  • Some people will say they use ñ while coding, or ê. Even if the Terminal has great:tm: support for UTF8, I'm not among them. I belive this is a tiny minority
  • I'm sure many people have that one dead key they wish they could get rid of. If this feature was builtin the terminal, it would allow a better coding experience for the people that only use those characters in the terminal anyways. This could also be profile based...

Do people also want that

For the user, It could be as simple a config value to disable dead keys using their key codes (?) such as

disable_dead_keys: [50]  # the 2/~ key code

Thanks a lot for you time, the Terminal is absolutely amazing and it just keeps getting better ! Cheers

@gpotter2 gpotter2 added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label May 7, 2020
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels May 7, 2020
@zadjii-msft
Copy link
Member

This doesn't seem entirely unreasonable to me. We might want to workshop how we specify these keys in json, but I think the idea sounds valid. I'm gonna summon our keyboard layout expert @lhecker to see if he's got any thoughts on the matter ☺️

(sorry for the long silence)

@zadjii-msft zadjii-msft added Area-Input Related to input processing (key presses, mouse, etc.) Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Product-Terminal The new Windows Terminal. labels Jun 9, 2020
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Jun 9, 2020
@zadjii-msft zadjii-msft added Help Wanted We encourage anyone to jump in on these. Needs-Tag-Fix Doesn't match tag requirements and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Jun 9, 2020
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Jun 9, 2020
@zadjii-msft zadjii-msft added this to the Terminal Backlog milestone Jun 9, 2020
@lhecker
Copy link
Member

lhecker commented Jun 9, 2020

Yeah that's probably relatively easy to implement. Add a config setting like so (minus the UB I introduced), and add a && !disabledDeadKeys.contains(vkey) here.
I'd be able to implement that next weekend or so. 👍

@gpotter2
Copy link
Author

Thanks a lot for looking into this !

@lhecker
Copy link
Member

lhecker commented Jun 14, 2020

I had the idea of adding a command called "passthrough" to the keybindings.
If you e.g. add a { "command": "passthrough", "keys": "~" }, binding it would then pass the key event (with the character ~) to the shell instead of deferring the event to the character event handler.
In order to support this I'd modify IKeyBindings::TryKeyChord to return a ternary instead of a boolean.
What do you think?

@lhecker
Copy link
Member

lhecker commented Sep 14, 2020

Ah! I forgot about this issue! While it's slightly cumbersome I believe this functionality can now be achieved in the v1.3 preview version using the new sendInput command.
If that's sufficient for you @gpotter2 would you like to try it out in the preview version?

@gpotter2
Copy link
Author

It's working great ! The only issue now is that there is no way to register AltGR in the current key binders :/

@lhecker
Copy link
Member

lhecker commented Sep 14, 2020

The current key bninding interface doesn't make a distinction between left and right Ctrl/Alt.
We'll have to extend that interface and teach it to do so first. It'll also require adding logic to make it parse e.g. "LeftCtrl"/"RrightCtrl" and teach it that "Ctrl" is an alias for the presence of either of those keys. Only then can we alias "AltGr" as "RightAlt+LeftCtrl". Unfortunately that's clearly another feature that needs to implemented unrelated to both sendInput and this issue. 🤔

@gpotter2
Copy link
Author

Actually, there's an issue: it seems the dead key are not consumed (which is the whole point of this issue), even if made a shortcut.
For instance on my AZERTY keyboard, there's a ^ that is a dead key. If i use:

{ "command": { "action": "sendInput", "input": "b" }, "keys": "^" }

If i then press once the ^ key (which is a dead key) then a, I'll get:

@lhecker
Copy link
Member

lhecker commented Sep 14, 2020

I'll investigate this. 👍

@ghost ghost added the In-PR This issue has a related PR label Sep 20, 2020
@ghost ghost added Needs-Tag-Fix Doesn't match tag requirements and removed In-PR This issue has a related PR labels Oct 19, 2020
DHowett pushed a commit that referenced this issue Oct 19, 2020
Let's assume the user has bound the dead key ^ to a sendInput command
that sends "b".  If the user presses the two keys ^a it'll produce "bâ",
despite us marking the key event as handled.  We can use `ToUnicodeEx`
to clear such dead keys from the keyboard state and should make use of
that for keybindings.  Unfortunately `SetKeyboardState` cannot be used
for this purpose as it doesn't clear the dead key state.

Validation
* Enabled a German keyboard layout
* Added the following two keybindings:
  { "command": { "action": "sendInput", "input": "x" }, "keys": "q" },
  { "command": { "action": "sendInput", "input": "b" }, "keys": "^" }
* Pressed the following keys → ensured that the given text is printed:
  * q → x
  * ´ → nothing
  * a → á
  * ^ → b
  * a → a (previously this would print: â)
  * ´ → nothing
  * ^ → b
  * a → a (unfortunately we cannot specifically clear only ^)

Closes #5784
@ghost ghost added the Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. label Oct 19, 2020
@gpotter2
Copy link
Author

Thanks a lot for your work on this !!!
❤️

DHowett pushed a commit that referenced this issue Oct 27, 2020
Let's assume the user has bound the dead key ^ to a sendInput command
that sends "b".  If the user presses the two keys ^a it'll produce "bâ",
despite us marking the key event as handled.  We can use `ToUnicodeEx`
to clear such dead keys from the keyboard state and should make use of
that for keybindings.  Unfortunately `SetKeyboardState` cannot be used
for this purpose as it doesn't clear the dead key state.

Validation
* Enabled a German keyboard layout
* Added the following two keybindings:
  { "command": { "action": "sendInput", "input": "x" }, "keys": "q" },
  { "command": { "action": "sendInput", "input": "b" }, "keys": "^" }
* Pressed the following keys → ensured that the given text is printed:
  * q → x
  * ´ → nothing
  * a → á
  * ^ → b
  * a → a (previously this would print: â)
  * ´ → nothing
  * ^ → b
  * a → a (unfortunately we cannot specifically clear only ^)

Closes #5784

(cherry picked from commit 4099aac)
@ghost
Copy link

ghost commented Nov 11, 2020

🎉This issue was addressed in #7686, which has now been successfully released as Windows Terminal v1.4.3141.0.:tada:

Handy links:

@ghost
Copy link

ghost commented Nov 11, 2020

🎉Windows Terminal v1.4.3141.0 has been released which incorporates this pull request.:tada:

Handy links:

@ghost
Copy link

ghost commented Nov 11, 2020

🎉This issue was addressed in #7686, which has now been successfully released as Windows Terminal Preview v1.5.3142.0.:tada:

Handy links:

@ghost
Copy link

ghost commented Nov 11, 2020

🎉Windows Terminal Preview v1.5.3142.0 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Input Related to input processing (key presses, mouse, etc.) Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Help Wanted We encourage anyone to jump in on these. Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants