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

NumLock/NumPad keys stopped working in 1.11 on Linux #24064

Closed
pesho opened this issue Apr 6, 2017 · 25 comments
Closed

NumLock/NumPad keys stopped working in 1.11 on Linux #24064

pesho opened this issue Apr 6, 2017 · 25 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority keybindings VS Code keybinding issues linux Issues with VS Code on Linux verified Verification succeeded

Comments

@pesho
Copy link

pesho commented Apr 6, 2017

  • 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"
    }
]
@panjiesw
Copy link

panjiesw commented Apr 6, 2017

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)

@wgerven
Copy link

wgerven commented Apr 6, 2017

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

@chrmarti
Copy link
Collaborator

chrmarti commented Apr 6, 2017

Related #24012

@chrmarti
Copy link
Collaborator

chrmarti commented Apr 6, 2017

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

@victor9000
Copy link

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

@jspaine
Copy link

jspaine commented Apr 6, 2017

@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

@pesho
Copy link
Author

pesho commented Apr 6, 2017

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.

@alexdima alexdima added the linux Issues with VS Code on Linux label Apr 6, 2017
@alexdima
Copy link
Member

alexdima commented Apr 6, 2017

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?

@alexdima alexdima added the info-needed Issue requires more information from poster label Apr 6, 2017
@alexdima
Copy link
Member

alexdima commented Apr 6, 2017

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

Could you please:

Check what Chromium does on your distribution

@jspaine
Copy link

jspaine commented Apr 6, 2017

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!

@alexdima alexdima changed the title NumPad keys stopped working in 1.11 NumLock with NumPad keys stopped working in 1.11 Apr 6, 2017
@alexdima
Copy link
Member

alexdima commented Apr 6, 2017

@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?

@pesho
Copy link
Author

pesho commented Apr 6, 2017

@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).

@pesho
Copy link
Author

pesho commented Apr 6, 2017

@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.

@pesho pesho changed the title NumLock with NumPad keys stopped working in 1.11 NumPad keys stopped working in 1.11 Apr 6, 2017
@pesho pesho changed the title NumPad keys stopped working in 1.11 NumPad keys stopped working in 1.11 on Linux Apr 6, 2017
@pesho
Copy link
Author

pesho commented Apr 6, 2017

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

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

@alexdima
Copy link
Member

alexdima commented Apr 6, 2017

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.

@pesho
Copy link
Author

pesho commented Apr 6, 2017

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

@alexdima alexdima changed the title NumPad keys stopped working in 1.11 on Linux NumLock/NumPad keys stopped working in 1.11 on Linux Apr 6, 2017
@alexdima alexdima added the keybindings VS Code keybinding issues label Apr 6, 2017
@victor9000
Copy link

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

{
    "keyboard.dispatch": "keyCode"
}

@pesho
Copy link
Author

pesho commented Apr 7, 2017

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.

@pesho
Copy link
Author

pesho commented Apr 7, 2017

...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

@pesho
Copy link
Author

pesho commented Apr 7, 2017

...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

@pesho
Copy link
Author

pesho commented Apr 7, 2017

@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.

@alexdima alexdima added important Issue identified as high-priority candidate Issue identified as probable candidate for fixing in the next release and removed info-needed Issue requires more information from poster labels Apr 10, 2017
@alexdima alexdima added this to the March Recovery 2017 (2) milestone Apr 10, 2017
@alexdima alexdima added the bug Issue identified by VS Code Team member as probable bug label Apr 10, 2017
@alexdima
Copy link
Member

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.

@pesho
Copy link
Author

pesho commented Apr 11, 2017

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

@jrieken
Copy link
Member

jrieken commented Apr 12, 2017

adding verified-label based on #24064 (comment)

@jrieken jrieken added the verified Verification succeeded label Apr 12, 2017
@egamma egamma removed the candidate Issue identified as probable candidate for fixing in the next release label Apr 12, 2017
@JulieMarie
Copy link

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!!

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority keybindings VS Code keybinding issues linux Issues with VS Code on Linux verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

10 participants