Many users have asked how to add KeyEvent
s to speed/improve keyboard input. This is just a random example. The technique is always the same. It requires that you manually modify KeyEventTranslations.tr
(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 KeyEvent
s to an already running Mathematica session, without changing the KeyEventTranslations.tr
? Alternatively: can we program Mathematica to backup KeyEventTranslations.tr
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).
Answer
This will add Quit
to Control+Q (and Alt+V Q Q):
FrontEndExecute[
FrontEnd`AddMenuCommands["MenuListQuitEvaluators",
{MenuItem["AddMenu &Quit",
FrontEnd`KernelExecute[ToExpression["Quit[]"]],
MenuKey["q", Modifiers -> {"Control"}],
System`MenuEvaluator -> Automatic]}]]
It only persists for the front end session.
Usually I keep the following in my KeyEventTranslations.tr file:
Item[KeyEvent["q", Modifiers -> {Control}],
FrontEndExecute[
FrontEnd`FrontEndToken[SelectedNotebook[], "EvaluatorQuit", Automatic]
]],
Comments
Post a Comment