Psreadline: Beta 4: problems with dead keys and custom keyboard layout (Neo2)

Created on 8 May 2019  路  14Comments  路  Source: PowerShell/PSReadLine

I use a custom keyboard layout called Neo2 offering multiple layers using modifier keys, e.g. <CAPS-LOCK>+<k> results in )
Since installing beta4 of PSReadline, every time I press <CAPS-LOCK> a @ character is added to my input, So instead of
git commit -am "message"
I end up "typing"
git commit @-am @"message@"

Environment data

PS version: 5.1.17763.316 / same for 6.2
PSReadline version: 2.0.0-beta4
os: 10.0.17763.470 (WinBuild.160101.0800)
PS file version: 10.0.17763.470 (WinBuild.160101.0800)
vi or standard edit mode.

Steps to reproduce or exception report

Install the Neo2 driver: https://github.com/neo-layout/neo-layout/blob/master/windows/Neo2.0_setup.exe
And add the "German (Neo 2.0)" keyboard layout to your input settings, open powershell and hit \

Issue-Bug

Most helpful comment

It looks ToUnicode is not reliable to identify dead keys for all keyboard layouts. I will try a more relaxed fix.

All 14 comments

I think this is not entirely specific to custom keyboard layouts, since this kind of problem can also be produced with the standard out-of-the-box fr-FR layout. (And likely any layout with similar features)

Specifically:
All FR layouts have some kind of dead keys such as ^/篓, 茅/2/~ or 猫/7/` (Normal/Caps/AltGr) on the standard AZERTY layout. When any dead key is depressed (Not specifically the ones related to Right Alt/Altr Gr.), the character @ gets outputed for the dead key press, in addition to the normal delayed behavior.

e.g. if I press Alt Gr + 7 then Spacebar, I expect ` to be output. Instead, I'll get @`

So I suspect this is more a problem with dead keys than a specific layout.

@SteveL-MSFT While this does fix #854, this is indeed a regression introduced in beta4 馃槬

cc @daxian-dbw

The same is happening here when I type ~, ^, ", '. My OS language is English and the keyboard is configured as United States-International.

Downgraded to 2.0.0-beta3 and it's working now.

PS version: 6.1.2
PSReadline version: 2.0.0-beta4
os: 10.0.17763.580 (WinBuild.160101.0800)
PS file version: 6.1.2

I just fetched and built your changes, but they don't work for me, unfortunately :-(

If I change
s = isDeadKey ? key.Key.ToString() : "@";
to
s = isDeadKey ? key.Key.ToString() : "\0";
then my meta keys work as they are supposed to.

But deadKey handling is still strange. E.g.:
<`><a><space><a> is supposed to result in 脿 a - and it does.
<a><`><space><a> is supposed to result in a`a but with PSReadline I get 脿`a

I verified the fix with US-international and the default French keyboard layouts, but not on Neo2.
Based on the code snippet you pasted above, it looks isDeadKey is false when it's supposed to be true, meaning the Win32 API ToUnicode at https://github.com/PowerShell/PSReadLine/blob/master/PSReadLine/Keys.cs#L150 doesn't return the expected results.

Do I have to install the German language before installing the Neo2 keyboard?

And add the "German (Neo 2.0)" keyboard layout to your input settings, open powershell and hit

Does the "German (Neo 2.0)" keyboard layout comes with Windows by default (available in the Language settings)?

Sorry, forget to mention that I can confirm the fix for French and US-international.

Unfortunately the Neo layout does not come with Windows, you'd have to install it first to add it to the Language settings. So this may not be worth the effort :-)

Based on the code snippet you pasted above, it looks isDeadKey is false when it's supposed to be true, meaning the Win32 API ToUnicode at https://github.com/PowerShell/PSReadLine/blob/master/PSReadLine/Keys.cs#L150 doesn't return the expected results.

Hmm, I'm guessing that the Win32 function ToUnicode doesn't work with the Neo driver well enough :(

It looks ToUnicode is not reliable to identify dead keys for all keyboard layouts. I will try a more relaxed fix.

@Snaptags and @MovGP0, I'm having difficulty to install the Neo keyboard layout. I ran https://github.com/neo-layout/neo-layout/blob/master/windows/Neo2.0_setup.exe, but then I don't know how to add the "German (Neo 2.0)" keyboard.

Here is what I did:

  1. Install Neo2.0_setup.exe with the following option. The installation succeeded
    image
  2. Install the "Getman (Getmany)" language.

Then I have no idea how to add the "German (Neo 2.0)" keyboard. Can you please help me with it?

@Snaptags and @MovGP0, also, what is the key chord to produce the dash character in Neo? Can you please give me a few more examples that require a dead key? (such as CAPS-LOCK+k results in ))

You don't need to install the german language pack or the AHK extension. Just install the 'Neo 2.0 Treiber' and restart the computer.

After the restart

  • Open Settings.
  • Click on Time & Language.
  • Click on Language.
  • Select your default language from the list.
  • Click the Options button.
  • Under the "Keyboards" section, click the Add a keyboard button.

It may be written as 'Deutsch (Neo2)' instead of 'German (Neo2)'.

When you have multiple languages installed, you can switch using the Windows+Space keys.

@MovGP0 Thanks, I will give it a try.

@daxian-dbw there are essentially three modifier keys. In the english QWERTY they would be located as:

  • [Shift]
  • Mod3 is [Caps Lock] or [#]
  • Mod4 is [Alt Gr] or [<]

By holding one or more modifier keys, you can switch between layers.

  • No modifier: lowercase characters
  • Shift: uppercase characters and diacradic symbols
  • Mod3: Special characters like brackets or dash
  • Shift + Mod3: lowercase greek letters
  • Mod4: ASCII control characters, like cursor and numkeys
  • Mod3 + Mod4: mathematical characters and uppercase greek

So basically just hold down the modifier keys and type anything. Every single key represents between 3 and 6 symbols.

@MovGP0 I successfully added the Neo keyboard. Will look into the issues with Neo. Thanks for your help!

Was this page helpful?
0 / 5 - 0 ratings