Using NotebookEventActions one can make MMA evaluate a function when a key is pressed.
For example:
SetOptions[
EvaluationNotebook[],
NotebookEventActions -> {{"KeyDown","x"} :> Print["You pressed \"x\"!"]}
]
will print a sentence every time the user presses "x" on the keyboard.
How do I use NotebookEventActions to do something when the user presses one of the function keys "F2", "F3, ..., "F12", or a special key, such as "pause"?
If this is not possible, then how can I make my program react to special keys with a mechanism other than NotebookEventActions? It is important that the change is local to one notebook, and that it can be made programmatically.
KeyEventTranslations.trbut it will be active across all notebooks. – Kuba Mar 04 '18 at 21:41KeyDown. – b3m2a1 Mar 04 '18 at 23:32EventHandler[InputField[], {{"KeyDown", 113} :> Print["!"]}]does not work, since Google says "F2" corresponds to 113, but FromCharacterCode[113] gives "q". – JEM_Mosig Mar 04 '18 at 23:44