is a notebook option that gives a list of actions to perform when specified events occur in connection with the notebook.
 
     
   NotebookEventActions
is a notebook option that gives a list of actions to perform when specified events occur in connection with the notebook.
Details
 
   - NotebookEventActions->{"event1":>action1,"event2":>action2,…} specifies that actioni should be evaluated whenever "eventi" occurs in connection with the notebook.
- The possible event specifications are the same as for EventHandler, with the following addition:
- 
      
      "WindowClose" window being closed 
- Settings for NotebookEventActions are often defined at the level of stylesheets, rather than for individual notebooks.
- By default, any action specified for an event by NotebookEventActions will override any default action that the Wolfram System would take for that event.
- The default behavior can be changed by including rules for PassEventsDown or PassEventsUp in the list given as the setting for NotebookEventActions.
Examples
open all close allBasic Examples (1)
Scope (3)
Set NotebookEventActions so that the notebook will change color when clicked:
Clicking the notebook changes its background:
Make an action occur when the ![TemplateBox[{return}, Key0, BaseStyle -> {ExampleText, FontWeight -> Plain, FontFamily -> Source Sans Pro}] TemplateBox[{return}, Key0, BaseStyle -> {ExampleText, FontWeight -> Plain, FontFamily -> Source Sans Pro}]](Files/NotebookEventActions.en/4.png) key is pressed:
 key is pressed:
Define actions for "MouseDown" and "MouseUp":
The background will be pink only while the mouse button is held down:
After the mouse is released, the notebook is back to its normal background:
Possible Issues (3)
This NotebookEventActions setting blocks the normal ![TemplateBox[{return}, Key0, BaseStyle -> {ExampleText, FontWeight -> Plain, FontFamily -> Source Sans Pro}] TemplateBox[{return}, Key0, BaseStyle -> {ExampleText, FontWeight -> Plain, FontFamily -> Source Sans Pro}]](Files/NotebookEventActions.en/8.png) key behavior:
 key behavior:
Pressing ![TemplateBox[{return}, Key0, BaseStyle -> {ExampleText, FontWeight -> Plain, FontFamily -> Source Sans Pro}] TemplateBox[{return}, Key0, BaseStyle -> {ExampleText, FontWeight -> Plain, FontFamily -> Source Sans Pro}]](Files/NotebookEventActions.en/10.png) changes the background but does not start a new line:
 changes the background but does not start a new line:
This inserts a newline as part of the action specified for "ReturnKeyDown":
Pressing ![TemplateBox[{return}, Key0, BaseStyle -> {ExampleText, FontWeight -> Plain, FontFamily -> Source Sans Pro}] TemplateBox[{return}, Key0, BaseStyle -> {ExampleText, FontWeight -> Plain, FontFamily -> Source Sans Pro}]](Files/NotebookEventActions.en/12.png) in this notebook inserts a newline as well as setting the background:
 in this notebook inserts a newline as well as setting the background:
Specify a NotebookEventActions setting that goes away after being activated once:
A single ![TemplateBox[{return}, Key0, BaseStyle -> {ExampleText, FontWeight -> Plain, FontFamily -> Source Sans Pro}] TemplateBox[{return}, Key0, BaseStyle -> {ExampleText, FontWeight -> Plain, FontFamily -> Source Sans Pro}]](Files/NotebookEventActions.en/15.png) changes the background without entering a newline:
 changes the background without entering a newline:
Also, NotebookEventActions has been reset to None:
History
Text
Wolfram Research (2007), NotebookEventActions, Wolfram Language function, https://reference.wolfram.com/language/ref/NotebookEventActions.html.
CMS
Wolfram Language. 2007. "NotebookEventActions." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/NotebookEventActions.html.
APA
Wolfram Language. (2007). NotebookEventActions. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NotebookEventActions.html
BibTeX
@misc{reference.wolfram_2025_notebookeventactions, author="Wolfram Research", title="{NotebookEventActions}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/NotebookEventActions.html}", note=[Accessed: 31-October-2025]}
BibLaTeX
@online{reference.wolfram_2025_notebookeventactions, organization={Wolfram Research}, title={NotebookEventActions}, year={2007}, url={https://reference.wolfram.com/language/ref/NotebookEventActions.html}, note=[Accessed: 31-October-2025]}
 
       
       
       
       
       
       
       
       
       
       
      ![TemplateBox[{return}, Key0, BaseStyle -> {ExampleText, FontWeight -> Plain, FontFamily -> Source Sans Pro}] TemplateBox[{return}, Key0, BaseStyle -> {ExampleText, FontWeight -> Plain, FontFamily -> Source Sans Pro}]](Files/NotebookEventActions.en/17.png) keystrokes add new lines as usual:
 keystrokes add new lines as usual: