title: Keyboard shortcut to quit kernel in Mathematica 5 and 7?
body: <p><a href="https://stackoverflow.com/questions/4209405/customizing-mathematica-shortcuts/4209612#4209612"><code>Here</code></a> is an explanation how to define a custom keyboard shortcut for quitting the kernel of the selected notebook by modifying the file <code>KeyEventTranslations.tr</code>. This file is located by default (under Windows) for <em>Mathematica</em> 5.2 in the folder</p>
  
  <pre><code>C:\Program Files\Wolfram Research\Mathematica\5.2\SystemFiles\FrontEnd\TextResources\Windows
  </code></pre>
  
  <p>and for <em>Mathematica</em> 7.0.1 in the folder</p>
  
  <pre><code>C:\Program Files\Wolfram Research\Mathematica\7.0\SystemFiles\FrontEnd\TextResources\Windows
  </code></pre>
  
  <p>In this file after <code>EventTranslations[{</code> I have added a line:</p>
  
  <pre><code>Item[KeyEvent["q", Modifiers -&gt; {Control}],FrontEndExecute[FrontEndToken[SelectedNotebook[],"EvaluatorQuit",Automatic]]]
  </code></pre>
  
  <p>But unfortunately after restarting <em>Mathematica</em> the shortcut <code>Control+q</code> does not work on both versions. </p>
  
  <p>Moreover, in <em>Mathematica</em> 7.0.1 executing the command </p>
  
  <pre><code>FrontEndExecute[FrontEndToken[SelectedNotebook[], "EvaluatorQuit", Automatic]]
  </code></pre>
  
  <p>and pressing "Quit" leads to an application error and closing <code>FrontEnd</code> with loosing all unsaved changes (I am using Windows 2000).</p>
  
  <p>What am I doing wrong?</p>
  
  <p><strong>EDIT:</strong> The problem was in missing comma after added <code>Item[...]</code> (thanks to belisarius). Here is the right line to add to <code>KeyEventTranslations.tr</code>:</p>
  
  <pre><code>Item[KeyEvent["q", Modifiers -&gt; {Control}],FrontEndExecute[FrontEndToken[SelectedNotebook[],"EvaluatorQuit",Automatic]]],
  </code></pre>
  
  <p>Now shortcut <code>Control+q</code> 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 <code>FrontEndExecute[FrontEndToken[SelectedNotebook[], "EvaluatorQuit", Automatic]]</code> in notebook).</p>