0

Is it possible to use the control key to exit Evil's insert mode? I'm currently using the following code to do it with TAB, but since control only seems to work as a modifier key, I'm not having any luck with it.

;; Map single control to ESC (with-eval-after-load 'evil-maps (define-key evil-insert-state-map (kbd "TAB") 'evil-force-normal-state))

Any thoughts?

brenns10
  • 103
  • 3
  • I'm a little late to this question, but in vim you can do `` to escape insert mode, and that binding exists in evil mode as well. Maybe not quite what you are looking for, but it is a way to leave insert mode with the control key. – Ricky Nelson Dec 17 '17 at 23:52

1 Answers1

3

No, you cannot, at least not within Emacs. Emacs only understands modifier keys that actually modify something, so CTRL alone will not be recognized.

Some programs (xcape, for instance) allow you to bind a modifier key to do something when it modifies something, and a different thing when you tap and release it. A common use case is to modify the CTRL key to act as ESC when tapped and released.

Dan
  • 32,584
  • 6
  • 98
  • 168
  • I had already found xcape and was hoping for an Emacs-only solution. But I guess I was expecting it to be impossible. Thanks for the answer! – brenns10 Jan 25 '17 at 05:13
  • 1
    FWIW, I was able to map Caps Lock in Ubuntu using `setxkbmap`, see [this](http://askubuntu.com/q/831707/156688) question. Then `Caps Lock` appears as `VoidSymbol` in Emacs, so I could do `(define-key evil-insert-state-map (kbd "") 'evil-normal-state)` to make Caps Lock work as ESC in `evil-mode` – Håkon Hægland Jan 25 '17 at 08:41