Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Many users have asked how to add KeyEvents to speed/improve keyboard input. This is just a random example. The technique is always the same. It requires that you manually modify (an important system file).

It always struck me as a bit odd that even power users propose to manually do this. Surely this system file is loaded into Mathematica at the start of a session (or not?), so it is perhaps possible to programmatically add the necessary KeyEvents to an already running Mathematica session. Of course in this case the new key bindings will only be temporary, but this might even be preferable in some cases.

So the question is: is it possible to programmatically add the necessary KeyEvents to an already running Mathematica session, without changing the Alternatively: can we program Mathematica to backup and programmatically modify it? I know this is possible, I just wonder if someone has done it.

And perhaps automatically reload the new version so that it takes effect right away?

The art of Quitting.

I take the occasion to post another item related to "saving keystrokes for your retirement": It recently came to my attention that many/most users when they want to quit the kernel, type Quit[].

Well...the good news are that you just need to type Quit (saving two keystrokes).

share|improve this question
Related: – Mr.Wizard Jun 9 '12 at 8:41
up vote 13 down vote accepted

This will add Quit to Control+Q (and Alt+V Q Q):

  {MenuItem["AddMenu &Quit",
    MenuKey["q", Modifiers -> {"Control"}],
    System`MenuEvaluator -> Automatic]}]]

It only persists for the front end session.

Usually I keep the following in my file:

Item[KeyEvent["q", Modifiers -> {Control}],
        FrontEnd`FrontEndToken[SelectedNotebook[], "EvaluatorQuit", Automatic]
share|improve this answer
@IstvánZachar it works the same even if you do not put the AddMenu string. I took it off – magma May 30 '12 at 15:04
I like the FrontEndExecute argument. TOTALLY undocumented, lol. Can the same thing be done with the KeyEventTranslations ? Perhaps with some equally undocumented AddKeyEvent command? – magma May 30 '12 at 15:10
@ magma - setting key events is documented. See the help on NotebookEventActions. – Chris Degnen May 30 '12 at 16:45
There is no way to add/overload KeyEventTranslations programmatically, but as we're seeing here, there are other ways to achieve similar effects. – John Fultz Jun 1 '12 at 8:42
@magma are you referring to either the "AddMenu &Quit" or "MenuListQuitEvaluators" string because I am not experiencing what described currently? – Liam Jul 7 '13 at 4:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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