.. note::
    :class: sphx-glr-download-link-note

    Click :ref:`here <sphx_glr_download_examples_keyboard_shortcuts.py>` to download the full example code
.. rst-class:: sphx-glr-example-title

.. _sphx_glr_examples_keyboard_shortcuts.py:


Keyboard shortcuts
==================

By default, mplcursors uses "t" to toggle interactivity and "d" to hide/show
annotation boxes.  These shortcuts can be customized.


.. image:: /examples/images/sphx_glr_keyboard_shortcuts_001.png
    :class: sphx-glr-single-img





.. code-block:: default


    import matplotlib.pyplot as plt
    import mplcursors

    fig, ax = plt.subplots()
    ax.plot(range(10), "o-")
    ax.set_title('Press "e" to enable/disable the datacursor\n'
                 'Press "h" to hide/show any annotation boxes')

    mplcursors.cursor(bindings={"toggle_visible": "h", "toggle_enabled": "e"})

    plt.show()


.. _sphx_glr_download_examples_keyboard_shortcuts.py:


.. only :: html

 .. container:: sphx-glr-footer
    :class: sphx-glr-footer-example



  .. container:: sphx-glr-download

     :download:`Download Python source code: keyboard_shortcuts.py <keyboard_shortcuts.py>`



  .. container:: sphx-glr-download

     :download:`Download Jupyter notebook: keyboard_shortcuts.ipynb <keyboard_shortcuts.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.readthedocs.io>`_
