Vscode: NumLock/NumPad keys stopped working in 1.11 on Linux

Created on 6 Apr 2017  路  25Comments  路  Source: microsoft/vscode

  • VSCode Version: 1.11.0
  • OS Version: Linux 4.9.20-1-lts (Arch Linux)

Steps to Reproduce:

  1. In vscode 1.11 try to use a numpad key to navigate in a file (e.g. left/right/up/down arrows, Home, End, PgUp, PgDn)

The default keybindings don't recognize the numpad keyboard keys anymore in v1.11 (they worked fine until 1.10). For example, the cursorEnd command is bound to the End keybinding by default, but I need to add NumPad1 manually in order for the numpad End key to work as well.

I had to add these to keybindings.json in order to restore the old behavior:

// Place your key bindings in this file to overwrite the defaults
[
    {
        "key": "numpad7",
        "command": "cursorHome",
        "when": "editorTextFocus"
    },
    {
        "key": "numpad1",
        "command": "cursorEnd",
        "when": "editorTextFocus"
    },
    {
        "key": "numpad8",
        "command": "cursorUp",
        "when": "editorTextFocus"
    },
    {
        "key": "numpad2",
        "command": "cursorDown",
        "when": "editorTextFocus"
    },
    {
        "key": "numpad4",
        "command": "cursorLeft",
        "when": "editorTextFocus"
    },
    {
        "key": "numpad6",
        "command": "cursorRight",
        "when": "editorTextFocus"
    },
    {
        "key": "numpad9",
        "command": "cursorPageUp",
        "when": "editorTextFocus"
    },
    {
        "key": "numpad3",
        "command": "cursorPageDown",
        "when": "editorTextFocus"
    }
]
bug important keybindings linux verified

Most helpful comment

Finally looked into why my keypad stopped working and found this thread. Confirmed as well that the fix above on the latest insiders build works for me too. Thanks!!

All 25 comments

Just finished upgrading via apt, I also have this issue on my laptop

VSCode Version: 1.11.0
OS: Linux Mint 18.1 (Ubuntu 16.04 lts)

Have the same issue. Downgraded for the time being.
Xubuntu 16.10, linux kernel 4.4.8

Related #24012

Anyone using a keyboard layout other than U.S. English?

Same for Ubuntu 16.04 LTS, numpad can no longer be used in place of arrow keys.

@chrmarti I'm using UK english

I put some more info in #23991 but now I don't think it's related to that:

I have problems with numpad keys too. With num lock off they do nothing, but work as number keys with it on. If I press a direction with numpad off, nothing happens, but then turn it on and type a number and the cursor will move and then put the number.

In the keyboard shortcuts editor numpad PgDn, for example, shows up as numpad3 whether num lock is on or off.

They work fine in the developer tools

The common factor seems to be that we are all using Linux.

Regarding the keyboard layouts, I switch between US English and Bulgarian. The issue exists in both layouts.

Hi, can you please try:

Attach what the C++ node module reads

  • open an editor. Run F1 > Developer: Inspect Keyboard Mappings. Save to a file and attach here.

Check what values we get from Chromium

  • Open the define keybindings widget (Keyboard Prefereces -> go to keybindings.json)
  • Press the problematic key
  • Hover over the input field (this shows the raw values we get from the keydown event)
    image
  • The first three values for code, keyCode and key are the values coming in from the browser keydown event

Check what Chromium does on your distribution

  • Install Chromium and visit https://jsfiddle.net/v1gz5c5m/1/ .
  • You could also compare the output with Firefox (the output should be the same, i.e. scan codes should match what you press ).

Read more about keybindings

https://github.com/Microsoft/vscode/wiki/Keybindings

Possible workaround

  • to go back to keyCode based dispatching you can use "keyboard.dispatch": "keyCode"

Related

21780

24107

Do you use Linux on actual hardware or do you run it in a VM/connect to it via some remoting software?

Is it possible this is the same issue as #24107?

Could you please:

Check what Chromium does on your distribution

I can't see F1 > Developer: Inspect Keyboard Mappings

From the keybindings widget:

  • Numpad 3/PgDn with Num Lock off:
    code: Numpad3, keyCode: 34, key: PageDown => UI: NumPad3, user settings: numpad3, dispatch: [Numpad3]
  • Numpad 3/PgDn with Num Lock on:
    code: Numpad3, keyCode: 99, key: 3 => UI: NumPad3, user settings: numpad3, dispatch: [Numpad3]

From the jsfiddle (Chrome 58):

  • Numpad 3/PgDn with Num Lock off:
    keydown --- code: Numpad3, keyCode: 34, key: PageDown
  • Numpad 3/PgDn with Num Lock on:
    keydown --- code: Numpad3, keyCode: 99, key: 3

Yes I'm using linux directly.

to go back to keyCode based dispatching you can use "keyboard.dispatch": "keyCode"

That works for me, thanks!

@jspaine Thank you for the extra information. This is quite helpful. Indeed, we appear to not honor NumLock in any way, as the low-level scan code remains the same when NumLock is on or off.

I need to read more (w3c) / test more about whom should honor the NumLock -- is it Chromium that should flip scan codes or should it be us doing it?

@alexandrudima here are my values:

  • Attach what the C++ node module reads: https://gist.github.com/pesho/5a7ec984922ce277668364690053bd7a

  • Check what values we get from Chromium: (using the numpad End key): Code: Numpad1, keyCode: 35, key: End => UI: NumPad1, user settings: numpad1, dispatch: [Numpad1]

  • Check what Chromium does on your distribution: (using the numpad End key): keydown --- code: Numpad1, keyCode: 35, key: End (Chrome), keydown --- code: Numpad1, keyCode: 35, key: End (Firefox)

Do you use Linux on actual hardware or do you run it in a VM/connect to it via some remoting software?

Actual hardware (an Asus laptop).

@alexandrudima also, the title change you did is inaccurate. The numpad keys don't work either with NumLock on or off. It's not an issue caused by NumLock on.

For the record, my NumLock is always off.

Is it possible this is the same issue as #24107?

I think it's the same. It was reported after the current one.

Thank you @pesho

The title change is for me to remember easily what this bug is about. Here is the rationale for my changing the title to include the word "NumLock" in the title:

AFAIK The Numpad1 key is a key that has its behavior impacted by NumLock.

  • depending on the NumLock state, the Numpad1 key produces a 1 or is the End key

It appears we get the same scan code for Numpad1, regardless of the NumLock state. I need to read some w3c spec to figure out if this is as designed or if this is an issue with Chromium. i.e. who should handle the NumLock state, the browsers or the applications built in browsers using KeyboardEvent.code.

All in all, we do not honor anymore the NumLock state. So IMHO it is NumLock related. Hence me adding NumLock to the title.

@alexandrudima got it, thank you for the explanation. Apologies for reverting the title, please feel free to change it back.

Following the suggestions above, I was able to resolve this on Ubuntu 16.04 LTS by specifying the following user settings:

{
    "keyboard.dispatch": "keyCode"
}

Here's some additional context, and more precise info. My laptop's keyboard looks like this:

kb_numpad_issue_new

The keys within the green border are what I refer to as NumPad. They are the ones which stopped working in v1.11, no matter whether NumLock is on or off.

The keys within the red border have mostly the same functions as the NumPad keys. These keys still work fine.

According to the jsfiddle, the red and green keys generate different codes on Linux:

  • End numpad key (green), in Chrome: keydown --- code: Numpad1, keyCode: 35, key: End
  • End numpad key (green), in Firefox: keydown --- code: Numpad1, keyCode: 35, key: End
  • End key (red), in Chrome: keydown --- code: End, keyCode: 35, key: End
  • End key (red), in Firefox: keydown --- code: End, keyCode: 35, key: End

As we can see, both Chrome and Firefox return the same codes on Linux. I'll post the same info from Windows a bit later.

...and on Windows, the jsfiddle shows the same codes in Chrome and Firefox actually, while in Edge they are undefined:

  • End numpad key (green) in Chrome (Windows): keydown --- code: Numpad1, keyCode: 35, key: End
  • End numpad key (green) in Firefox (Windows): keydown --- code: Numpad1, keyCode: 35, key: End
  • End numpad key (green) in Edge (Windows): keydown --- code: undefined, keyCode: 35, key: End
  • End key (red) in Chrome (Windows): keydown --- code: End, keyCode: 35, key: End
  • End key (red) in Firefox (Windows): keydown --- code: End, keyCode: 35, key: End
  • End key (red) in Edge (Windows): keydown --- code: undefined, keyCode: 35, key: End

...seeing that the jsfiddle codes are the same in Windows browsers as in Linux, I also installed VSCode on Windows to check what it sees differently. As expected, the numpad keys still work fine on Windows in v1.11.

  • Attach what the C++ node module reads (on Windows):
    keymappings-win.txt

  • Check what values we get from Chromium (on Windows):

    • End numpad key (green) on Windows: code: Numpad1, keyCode: 35, key: End => UI: End, user settings: end, dispatch: End
    • End key (red) on Windows: code: End, keyCode: 35, key: End => UI: End, user settings: end, dispatch: End

@alexandrudima so this difference between my values on Linux and Windows seems to be the most interesting part:

  • End numpad key (green) on Linux: code: Numpad1, keyCode: 35, key: End => UI: NumPad1, user settings: numpad1, dispatch: [Numpad1]
  • End numpad key (green) on Windows: code: Numpad1, keyCode: 35, key: End => UI: End, user settings: end, dispatch: End

As mentioned, on Linux this key doesn't work anymore, on Windows it still works fine. code, keyCode, and key are the same on both platforms.

Can someone please verify this works on the latest Insiders release (from today). i.e. this should now work even without the setting "keyboard.dispatch": "keyCode" on the Insiders build.

@alexandrudima confirming, it's fixed for me in the latest Insiders build (1.12.0-1491892095_amd64).

adding verified-label based on https://github.com/Microsoft/vscode/issues/24064#issuecomment-293240345

Finally looked into why my keypad stopped working and found this thread. Confirmed as well that the fix above on the latest insiders build works for me too. Thanks!!

Was this page helpful?
0 / 5 - 0 ratings