Ctrl+arrow key sends unrelated combination to atom


#1

I recently uninstalled and updated atom and it’s plugins. After that whenever I use the shortcuts bound to ctrl-arrow key it doesn’t work.

On investigating using the keybinding resolver, I see that the combination sent to atom, when I press Ctrl-right (or other Ctrl-arrow key) is Ctrl-convert (or other weird combinations, see picture below).

But when I press only the up, down right or left keys I get the right keys sent to atom (see picture below)

More specifically, the following combinations are sent to atom:

ctrl-right sends ctrl-nonconvert
ctrl-left sends ctrl-convert
ctrl-up sends ctrl-katakana (!!!)
ctrl-down sends ctrl-enter

I am not able to trace the origin of this error. I thought it may be OS related but I am able to use ctrl-right or ctrl-left to jump words in firefox and other text editors such as gedit.

OS: Ubuntu 14.04
atom: 1.12.5
plugins:

  • Hydrogen@1.0.1
  • atom-light-ui@0.46.0
  • autocomplete-python@1.8.12
  • file-header@1.12.1
  • git-diff-details@1.4.0
  • linter@1.11.18
  • linter-flake8@2.1.1
  • linter-markdown@3.0.2
  • minimap@4.25.6
  • python-indent@1.0.0
  • terminal-plus@0.14.5

#2

Is your Ubuntu set up with multiple keyboard layouts? What is your default and current layout?


#3

HI Ben3eeE,

Here are my current and default keyboard settings. I launch atom from the terminal.

╭─node1@master ~
╰─➤ setxkbmap -query
rules: base
model: pc105
layout: us

╭─node1@master ~
╰─➤ cat /etc/default/keyboard

XKBMODEL=“pc105"
XKBLAYOUT=“us"
XKBVARIANT=”“
XKBOPTIONS=””


#4

Interesting, the reason I am asking is because there is a bug in chromium where keystrokes using the Ctrl key resolve incorrectly on Linux that we are affected by currently. We are tracking an issue where keystrokes using the Ctrl key seem to favor the default layout instead of the active layout over here: https://github.com/atom/atom/issues/13170.

This sounds like a different issue so I have some additional questions:

  • Can you reproduce the problem in safe mode atom --safe?
  • Can you post the results of typing some failing keystrokes after running the following devtools console script:
document.addEventListener('keydown', e => console.log(e), true)
  • Do you have chromium installed to check the same script there?

While we investigate the cause of this you might be able to work around it using the public keystroke resolver API by adding something like this to your init.coffee, repeating for other failing keystrokes.

atom.keymaps.addKeystrokeResolver ({event}) ->
  if event.code is 'ArrowRight' and event.ctrlKey and event.type is 'keydown'
    return 'ctrl-right'

#5

Hi again!

Thank you for the reply and the workaround.

I was able to reproduce the same error with atom --safe.
I get the same set of improperly resolved keystrokes.

Here are the console logs from atom --safe and google-chrome. We don’t have chromium installed.

It is just the screenshot, if you want the full log please let me know I’ll put it on pastebin.

According to these both google-chrome and atom --safe seem to resolve the keystrokes incorrectly. But in google-chrome the actions work. i.e if i use Ctrl-left / Ctrl-right I can jump before or after a word. This happens even though the keystrokes are resolved incorrectly.


#6

Hi Ben3eeE,

Just a tiny update. I was editing the init,coffee to put in your workaround. It didn’t work right away but after replacing event.code is 'ArrowRight' with event.keyIdentifier is 'Right' it worked. I thought this info may be useful to you.

The following are the keys I had to include in the workaround

atom.keymaps.addKeystrokeResolver ({event}) ->
  if event.keyIdentifier is 'Right' and event.ctrlKey and event.type is 'keydown'
    return 'ctrl-right'
atom.keymaps.addKeystrokeResolver ({event}) ->
  if event.keyIdentifier is 'Left' and event.ctrlKey and event.type is 'keydown'
    return 'ctrl-left'
atom.keymaps.addKeystrokeResolver ({event}) ->
  if event.keyIdentifier is 'Up' and event.ctrlKey and event.type is 'keydown'
    return 'ctrl-up'
atom.keymaps.addKeystrokeResolver ({event}) ->
  if event.keyIdentifier is 'Down' and event.ctrlKey and event.type is 'keydown'
    return 'ctrl-down'
atom.keymaps.addKeystrokeResolver ({event}) ->
  if event.keyIdentifier is 'Insert' and event.ctrlKey and event.type is 'keydown'
    return 'ctrl-insert'
atom.keymaps.addKeystrokeResolver ({event}) ->
  if event.keyIdentifier is 'U+007F' and event.ctrlKey and event.type is 'keydown'
    return 'ctrl-delete'
atom.keymaps.addKeystrokeResolver ({event}) ->
  if event.keyIdentifier is 'Home' and event.ctrlKey and event.type is 'keydown'
    return 'ctrl-home'
atom.keymaps.addKeystrokeResolver ({event}) ->
  if event.keyIdentifier is 'End' and event.ctrlKey and event.type is 'keydown'
    return 'ctrl-end'
atom.keymaps.addKeystrokeResolver ({event}) ->
  if event.keyIdentifier is 'PageUp' and event.ctrlKey and event.type is 'keydown'
    return 'ctrl-pageup'
atom.keymaps.addKeystrokeResolver ({event}) ->
  if event.keyIdentifier is 'PageDown' and event.ctrlKey and event.type is 'keydown'
    return 'ctrl-pagedown'

#7

Hey thank you very much for all the information you gathered on this issue :slight_smile:

We are now tracking the issue of Ctrl on linux here:


#8

Hey again @raghulmz

Atom 1.12.7 was released which contained a fix for Atom resolving incorrectly when the Ctrl modifier was used. Do you still experience this issue in Atom 1.12.7?