Consider the following code:
timesXpressed = 0;
SetOptions[EvaluationNotebook[],
NotebookEventActions -> {{"KeyDown", "x"} :> timesXpressed++}]
Dynamic[timesXpressed]
It counts the number of times the key x
is pressed. However, in intercepting the key presses, they're no longer actually typed in the notebook. I suspect adding an additional action to type x
in the notebook when the key is down might fix this, but I don't know such an action.
timesXpressed
. Please run$Version
and include this information. $\endgroup$ref/NotebookEventActions
/Details
: The default behavior can be changed by including rules for PassEventsDown or PassEventsUp in the list given as the setting for NotebookEventActions. $\endgroup$