Registry / web-framework / ipyevents

ipyevents

JSON →
library2.0.4pypypi✓ verified 84d ago

ipyevents provides a custom widget for capturing and returning mouse and keyboard events from Jupyter widgets to Python. It enables adding interactive features like keyboard shortcuts, reacting to clicks on images, and handling arbitrary mouse/keyboard events within a Jupyter environment. The current version is 2.0.4, targeting JupyterLab 3 and above. Releases are driven by compatibility with JupyterLab versions and feature additions.

pip install ipyevents
INSTALL
IMPORT
SIG · IPYEVENTS
I
ipyevents
web-frameworkpythonv2.0.4
Install
5.1s avg
Import
1864ms
Disk
78MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 1.966s · 86MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 5.1s · import 1.762s · 86MB
78MB installed
● package 78MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Event
from ipyevents import Event

This quickstart creates a Label widget and an Event listener attached to it. It watches for 'click', 'keydown', and 'mouseenter' events, displaying event information in an HTML widget. This demonstrates how to capture browser events and process them in Python.

from ipywidgets import Label, HTML, display from ipyevents import Event l = Label('Click or type on me!') l.layout.border = '2px solid red' h = HTML('Event info') d = Event(source=l, watched_events=['click', 'keydown', 'mouseenter']) def handle_event(event): lines = [f'{k}: {v}' for k, v in event.items()] content = '<br>'.join(lines) h.value = content d.on_dom_event(handle_event) display(l, h)
Debug
Known issues
breakingipyevents versions 2.0.0 and higher are only built for JupyterLab 3 and up. If you are using JupyterLab 2, you must use ipyevents version 0.9.0 or earlier.
fix
Ensure your ipyevents version matches your JupyterLab version. Upgrade JupyterLab to version 3+ for ipyevents 2.x, or downgrade ipyevents to 0.9.0 or earlier for JupyterLab 2.
affects: <2.0.0 (for JupyterLab 3+), >=2.0.0 (for JupyterLab 2)
gotchaWhen watching keyboard events, ipyevents will grab the focus of the browser on the source widget. This prevents key presses from being passed to the notebook's default handlers (e.g., for cell navigation or commands).
fix
Be aware that keyboard input will be directed to the watched widget. This is intended behavior to prevent accidental notebook actions. You can style the focused element (e.g., with a blue border) to make it clear which element has focus.
affects: All versions
gotchaHigh-frequency events like 'mousemove' or 'wheel' can generate a large volume of messages between the frontend and backend, potentially leading to performance issues.
fix
Utilize the `throttle_or_debounce` and `wait` parameters of the `Event` widget to limit the rate at which events are passed to Python. 'throttle' is good for `mousemove`/`wheel`, 'debounce' for limiting repeated key strokes or clicks.
affects: All versions
gotchaThe `prevent_default_action` property may not function correctly for 'wheel' events, meaning the browser's default scroll behavior might still occur.
fix
If `prevent_default_action` is critical for 'wheel' events, test thoroughly. Consider alternative approaches or monitor the GitHub issues for a fix. There is no direct workaround mentioned in documentation.
affects: Unspecified, reported in Issue #76
Errors
Common errors & fixes
Module ipyevents, semver range X.Y.Z is not registered as a widget module
This error typically occurs when the `ipyevents` JupyterLab extension is not correctly installed or enabled, or if there's a version mismatch between `ipyevents` and JupyterLab (especially when using ipyevents versions < 2.0.0 with JupyterLab 3+).
fix
Ensure `ipyevents` is installed and the JupyterLab extension is correctly linked. For `ipyevents` 2.0.0+ with JupyterLab 3+, `pip install ipyevents` should be sufficient, as it automatically handles the lab extension. If issues persist, try `jupyter labextension install @jupyter-widgets/jupyterlab-manager ipyevents` and restart JupyterLab.
ModuleNotFoundError: No module named 'ipyevents'
The `ipyevents` package is not installed in the Python environment currently being used by your Jupyter kernel, or the kernel's environment does not match where `ipyevents` was installed.
fix
Install the package using pip: `pip install ipyevents`. If using Anaconda, ensure it's installed in the correct environment or try `conda install -c conda-forge ipyevents`. After installation, restart your Jupyter kernel.
Keyboard events (e.g., keydown) are not firing or not propagating to Python.
For `ipyevents` to capture keyboard events, the `Event` widget needs to have focus in the browser. Additionally, when `ipyevents` captures keyboard events, it intentionally prevents them from propagating further to the notebook to avoid unintended actions.
fix
Ensure the widget linked as the `source` for `ipyevents.Event` has focus (e.g., by clicking on it) in the Jupyter interface. Be aware that once `ipyevents` captures a keyboard event, it will not be processed by the notebook itself.
Error displaying widget
This is a generic error often indicating a problem with Jupyter widgets, which `ipyevents` is built upon. It can be due to corrupted installations, outdated `ipywidgets` or `jupyterlab-widgets` packages, or a mismatch in versions between the Python backend and the JavaScript frontend.
fix
Update `jupyterlab`, `ipywidgets`, and `jupyterlab-widgets` to their latest compatible versions: `pip install -U jupyterlab ipywidgets jupyterlab-widgets`. Clearing your browser cache and restarting JupyterLab might also resolve the issue.
Upgrade
Version history
2.0.4latest on PyPI · released Sep 15, 2025
Audit
Dependencies
ipywidgetsrequiredipyevents is built on top of ipywidgets to provide event handling for Jupyter widgets.
pythonrequiredRequires Python 3.9 or higher.
Agent activity
4 hits · last 30 days
node
4
Resources
ipyevents — pip install ipyevents · libregistry