I set (global-set-key (kbd "H-g") 'keyboard-quit).

When the minibuffer is open and waiting for input, and I want to quit out of it, when I hit H-g, the bell rings and I see the Quit message, but the minibuffer remains open and accepting input. C-g works as expected: closes the minibuffer.

How can I make H-g quit the minibuffer?

  • 2
    Use keyboard-escape-quit instead.
    – abo-abo
    Commented Jan 2, 2015 at 17:42
  • 1
    When in the minibuffer, C-g calls abort-recursive-edit (you can see this via C-h k C-g when in the minibuffer). That's another command you can consider. However, there are a lot of minibuffer maps (try M-x apropos minibuffer map), and I'm not sure which ones inherit from which.
    – Dan
    Commented Jan 2, 2015 at 17:43
  • OK, that makes sense. Is there a way I can simply alias H-g to C-g such that H-g will do whatever C-g does in the current context? Commented Jan 2, 2015 at 18:12
  • More details about this topic: reddit.com/r/emacs/comments/fk1kow/weekly_tipstricketc_thread/… Commented Mar 23, 2020 at 20:31

1 Answer 1


Thanks to #emacs, I learned that (global-set-key (kbd "H-g") (kbd "C-g")) will work for this. C-g runs whatever command it is bound to, and now H-g will run a keyboard macro that consists of C-g, so it does exactly whatever C-g would.

A slight oddity is that because H-g is now bound to a keyboard macro, after hitting it, I see the keyboard macro message "After 0 kbd macro iterations: Quit", because that's exactly what it's doing -- quitting.

  • i was searching exactly for aliasing Ctrl-G and your solution helped.... thanks a ton, dear...
    – Saravana
    Commented Jul 29, 2015 at 8:39
  • If this is the answer, OP, please consider accepting it.
    – Drew
    Commented Jan 14, 2019 at 3:42

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.