2

Here is an explanation how to define a custom keyboard shortcut for quitting the kernel of the selected notebook by modifying the file KeyEventTranslations.tr. This file is located by default (under Windows) for Mathematica 5.2 in the folder

C:\Program Files\Wolfram Research\Mathematica\5.2\SystemFiles\FrontEnd\TextResources\Windows

and for Mathematica 7.0.1 in the folder

C:\Program Files\Wolfram Research\Mathematica\7.0\SystemFiles\FrontEnd\TextResources\Windows

In this file after EventTranslations[{ I have added a line:

Item[KeyEvent["q", Modifiers -> {Control}],FrontEndExecute[FrontEndToken[SelectedNotebook[],"EvaluatorQuit",Automatic]]]

But unfortunately after restarting Mathematica the shortcut Control+q does not work on both versions.

Moreover, in Mathematica 7.0.1 executing the command

FrontEndExecute[FrontEndToken[SelectedNotebook[], "EvaluatorQuit", Automatic]]

and pressing "Quit" leads to an application error and closing FrontEnd with loosing all unsaved changes (I am using Windows 2000).

What am I doing wrong?

EDIT: The problem was in missing comma after added Item[...] (thanks to belisarius). Here is the right line to add to KeyEventTranslations.tr:

Item[KeyEvent["q", Modifiers -> {Control}],FrontEndExecute[FrontEndToken[SelectedNotebook[],"EvaluatorQuit",Automatic]]],

Now shortcut Control+q works nice both in Mathematica 5.2 and 7.0.1. But the above bug with "application error" still appears (not when using the shortcut but only when evaluating FrontEndExecute[FrontEndToken[SelectedNotebook[], "EvaluatorQuit", Automatic]] in notebook).

Community
  • 1
  • 1
Alexey Popkov
  • 9,355
  • 4
  • 42
  • 93

1 Answers1

2

This answer and the associated comments may help you.

HTH!

BTW ... I did the same in v7 and it worked. On what version are you having trouble?

Just a note: Be very careful with the syntax Verify that every Item[Keyevent ends with a comma, except the last one.

Community
  • 1
  • 1
Dr. belisarius
  • 60,527
  • 15
  • 115
  • 190