I'm not a fan of hitting escape 3 times so I am trying to have the same functionality with two key presses.

I have tried the following:

(define-key key-translation-map (kbd "<ESC> <ESC>") 'keyboard-escape-quit)

This doesn't work and it actually seems to break the normal <ESC> <ESC> <ESC> functionality as well.

Any Ideas on how to do this?

  • 2
    Why don't you just do (global-set-key (kbd "<ESC> <ESC>") 'keyboard-escape-quit)?
    – JeanPierre
    Jul 5, 2017 at 20:05
  • M-ESC ESC is what I have by default from emacs Jul 5, 2017 at 21:05
  • @JeanPierre has the correct solution, thanks ! Jul 6, 2017 at 14:09

2 Answers 2


This binding is in the global keymap. Generally key bindings that work in most or all buffers are in the global keymap. If in doubt, see How can I find out in which keymap a key is bound? to check.

So you can simply call

(global-set-key (kbd "<ESC> <ESC>") 'keyboard-escape-quit)

This overrides the previous binding of ESC ESC as a prefix. Note that if some package subsequently tries to set up a binding with ESC ESC as a prefix, this will signal an error; but this is not a commonly used prefix so you should be fine.

If you use Emacs in Unix-style terminals, this will break the use of Escape function key to encode Alt+function key (or Meta+function key in Emacs tradition), because function keys are encoded as character sequences that start with ESC. This is the reason why Emacs defines ESC ESC ESC rather than ESC ESC as a default binding. If that doesn't mean anything to you, forget I mentioned it.


Press C-g instead. It is shorter and works everywhere.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.