Skip to content

Commit

Permalink
update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Scheltienne committed Dec 3, 2024
1 parent 2a73da2 commit e6fc8cf
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
7 changes: 5 additions & 2 deletions doc/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ This is the reference for classes (``CamelCase`` names) and functions
:hidden:

audio.rst
trigger.rst
keyboard.rst
time.rst
trigger.rst
utilities.rst

.. include:: audio.rst

.. include:: trigger.rst
.. include:: keyboard.rst

.. include:: time.rst

.. include:: trigger.rst

.. include:: utilities.rst
32 changes: 32 additions & 0 deletions doc/api/keyboard.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.. include:: ../links.inc

Keyboard
--------

To interact with the keyboard during an experiment, you can use a
:class:`~stimuli.keyboard.Keyboard` object which monitors in a separate thread for key
inputs.

.. curentmodule:: stimuli.keyboard

.. autosummary::
:toctree: ../generated/api

Keyboard
KeyEvent

Example usage::

from stimuli.keyboard import Keyboard
from stimuli.time import sleep


kb = Keyboard(keys=["esc", "space"]).start(suppress=True)
while True:
events = kb.get_keys()
if any(event.key == "esc" for event in events):
print("Escape key pressed")
break
spaces = [event.key == "space" for event in events]
print(f"Space bar pressed {spaces.count(True)} times in the last 500 ms.")
sleep(0.5)
1 change: 1 addition & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
"sounddevice",
}
)
intersphinx_mapping["pynput"] = ("https://pynput.readthedocs.io/en/stable/", None)
intersphinx_timeout = 5

# -- sphinx-issues -----------------------------------------------------------
Expand Down

0 comments on commit e6fc8cf

Please sign in to comment.