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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapping capslock to esc has issues #854

Closed
billti opened this issue Oct 6, 2016 · 24 comments

Comments

Projects
None yet
@billti
Copy link

commented Oct 6, 2016


Please thumbs-up 馃憤 this issue if it personally affects you! You can do this by clicking on the emoji-face on the top right of this post. Issues with more thumbs-up will be prioritized.


What did you do?

Attempted to map the caps lock key to the escape key, via the below in keybindings.json

{"key": "capslock", "command": "extension.vim_escape"} 

Note: I also tried via the below, using "capslock" and "", but this had no effect, as it appears from the codebase <CapsLock> isn't recognized notation.

{
    "vim.insertModeKeyBindings": [
        {
            "before": ["capslock"],
            "after": ["<Esc>"]
        }
    ]
}

What did you expect to happen?

This should allow me to exit insert mode via the close-by caplock key.

What happened instead?

It does kinda work via the first form above, however if also toggles caps lock on/off, which makes it impossible to use (as every key press is then a capital after exiting insert mode). Preferably the "vim.insertModeKeyBindings" would work, and recognize the capslock key and intercept it - preventing it from toggling caps-lock.

Technical details:

  • VSCode Version: 1.5.3
  • VsCodeVim Version: 0.3.0
  • OS: Windows 10
@jpoon

This comment has been minimized.

Copy link
Member

commented Oct 7, 2016

Interestingly, I don't see the capslock key being bubbled up into our extension. We'll need to ask VS Code to add this to their extension API.

@billti

This comment has been minimized.

Copy link
Author

commented Oct 8, 2016

Actually, I just noticed even in Windows this usually requires some system changes via the registry or a utility to work correctly - so maybe it wasn't as simple as I hoped :-/ See http://vim.wikia.com/wiki/VimTip75

@johnfn

This comment has been minimized.

Copy link
Member

commented Oct 10, 2016

Yeah, Vim does not support caps lock mapping. People generally map it with some sort of broader keymapping program.

@johnfn johnfn closed this Oct 10, 2016

@vyorkin

This comment has been minimized.

Copy link

commented Oct 10, 2016

for Mac OS X I personally use Seil + Karabiner or Karabiner-Elements (if you are on Sierra).
you could take a look at this awesome post: http://stevelosh.com/blog/2012/10/a-modern-space-cadet/

@ljbuza

This comment has been minimized.

Copy link

commented Nov 26, 2016

On Linux Gnome desktops, Tweak Tool, under the "Typing" menu, will let you set your cap lock behavior. Setting it to "Make Caps Lock an additional ESC" works well for me.

@fkjogu

This comment has been minimized.

Copy link

commented Apr 6, 2017

Doing

setxkbmap -option caps:swapescape

on Linux swaps the escape and caps lock Xorg wide. But since code 1.11 this extension does not recognise this. To get out of insert mode, I have to press the original esc key, which at the same time toggles CAPS. This is really annoying.

Might be a problem with code itself: microsoft/vscode/issues/23991

@johnfn

This comment has been minimized.

Copy link
Member

commented Apr 6, 2017

Would probably be good to test with other parts of VSCode that use an ESC key to trigger something. We don't really have anything to do with capslock binding, unfortunately!

@tallpants

This comment has been minimized.

Copy link

commented Apr 6, 2017

It's definitely an issue with VS Code itself. Going back to 1.10 brings back the expected behavior, so it's something in the 1.11 update that's broken it.

@johnfn

This comment has been minimized.

Copy link
Member

commented Apr 6, 2017

@areyoureddy In that case, definitely go open up an issue on their repository then. :)

@tallpants

This comment has been minimized.

Copy link

commented Apr 6, 2017

microsoft/vscode#23991 Already done 馃憤

@Fr4nks

This comment has been minimized.

Copy link

commented May 24, 2017

Issue resolved?
keybindings.json
// Place your key bindings in this file to overwrite the defaults
[ {"key": "capslock", "command": "extension.vim_escape",
"when": "editorTextFocus && vim.active && !inDebugRepl" }
]

Ubuntu 16.04, VS Code 12.2.2
Doesn't work correctly in window 10.

@freddie-freeloader

This comment has been minimized.

Copy link

commented Jun 4, 2017

@Fr4nks This works for me just well under Linux.

@GummyDonut

This comment has been minimized.

Copy link

commented Jun 25, 2017

@Fr4nks solution worked for me to, thank.

@nayzawoo

This comment has been minimized.

Copy link

commented Jun 30, 2017

@Fr4nks Thanks!

@nazarimilad

This comment has been minimized.

Copy link

commented Jul 20, 2017

@Fr4nks First it didn't work for me. But after adding "keyboard.dispatch": "keyCode" in the settings file which was suggested as a workaround here, it's now working correctly.

VS Code version: 1.14.1

@hui00

This comment has been minimized.

Copy link

commented Sep 10, 2017

@Fr4nks thank you!

@HackerDeez

This comment has been minimized.

Copy link

commented Feb 7, 2018

@Fr4nks Thanks!

@Ding-Fan

This comment has been minimized.

Copy link
Contributor

commented Apr 7, 2018

I put this in keybinds.json

// Place your key bindings in this file to overwrite the defaults
[
  {
    "key": "capslock", 
    "command": "extension.vim_escape",
    "when": "editorTextFocus && vim.active && !inDebugRepl" 
  }
]

And toggle this in User Settings

"keyboard.dispatch": "keyCode"

Now I can use caps lock as esc in vim insert mode. But
I have to press caps lock again because it capitalize my letters. 馃槗

@Chillee

This comment has been minimized.

Copy link
Member

commented Apr 9, 2018

@Ding-Fan I suggest using some kind of external caps lock to escape rebinding program. I use caps2esc on Arch Linux.

@Ding-Fan

This comment has been minimized.

Copy link
Contributor

commented Apr 9, 2018

@Chillee I'm using Karabiner-Elements on macOS now, it's amazing. 馃槂

@mmyoungman

This comment has been minimized.

Copy link

commented Jun 11, 2018

In case it is of use to anyone, on macOS, I had set capslock to be escape, and it was previously working fine, but after using setting sync to import my settings, I stopped being able to get out of insert mode. It turned out that "vim.enableNeovim": true, was the culprit. I set it to false and everything was fine again.

@janhesters

This comment has been minimized.

Copy link

commented Dec 21, 2018

@Gesmir

This comment has been minimized.

Copy link

commented Mar 21, 2019

On Fedora 29 I just needed to change an option in the Settings (File > Preference > Settings).

Keyboard: Dispatch "keyCode"

@bergmul

This comment has been minimized.

Copy link

commented Mar 27, 2019

@Ding-Fan I suggest using some kind of external caps lock to escape rebinding program. I use caps2esc on Arch Linux.

I'm also using caps2esc and it works fine everywhere but in code. Sometimes it works for a couple of minutes, then pressing capslock does not trigger esc anymore.

EDIT: Adding "keyboard.dispatch": "keyCode" to user configs solves the problem. Thank you, @Fr4nks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can鈥檛 perform that action at this time.