<h3 dir="auto">Bug summary</h3>
<p dir="auto">On Windows, but not on Linux, with Python 3.9.<strong>8</strong> installed, key_press_events both work for the two examples from the MPL documentation:</p>
<p dir="auto"><a href="https://matplotlib.org/stable/gallery/event_handling/keypress_demo.html?highlight=key_press_event" rel="nofollow">Keypress demo</a></p>
<p dir="auto"><a href="https://matplotlib.org/stable/gallery/user_interfaces/embedding_in_tk_sgskip.html" rel="nofollow">Embedding TkInter demo</a></p>
<p dir="auto">The "Keypress demo" will <strong>not</strong> work with a clean install of Python 3.9.<strong>9</strong> (i.e one not upgraded from an earlier Python 3.9.x release. Deleting a previous install <strong>and</strong> obliterating the install directory is fine. Just upgrading, or uninstalling without obliteration, are not enough.</p>
<p dir="auto">The problem exists in Python 3.10 on Windows.</p>
<p dir="auto">The problem is not there for the Qt5Agg backend.</p>
<h3 dir="auto">Code for reproduction</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="1. Perform a clean install of Python 3.9.9 on Windows.
2. Install matplotlib.
3. Copy the code from the
[Keypress demo](https://matplotlib.org/stable/gallery/event_handling/keypress_demo.html?highlight=key_press_event) in to a file.
4. Run it.
5. Press some keys.
5. Note stdout."><pre class="notranslate"><span class="pl-c1">1.</span> <span class="pl-v">Perform</span> <span class="pl-s1">a</span> <span class="pl-s1">clean</span> <span class="pl-s1">install</span> <span class="pl-s1">of</span> <span class="pl-v">Python</span> <span class="pl-c1">3.9</span>.<span class="pl-c1">9</span> <span class="pl-s1">on</span> <span class="pl-v">Windows</span>.
<span class="pl-c1">2.</span> <span class="pl-v">Install</span> <span class="pl-s1">matplotlib</span>.
<span class="pl-c1">3.</span> <span class="pl-v">Copy</span> <span class="pl-s1">the</span> <span class="pl-s1">code</span> <span class="pl-s1">from</span> <span class="pl-s1">the</span>
[<span class="pl-v">Keypress</span> <span class="pl-s1">demo</span>](<span class="pl-s1">https</span>:<span class="pl-c1">//</span><span class="pl-s1">matplotlib</span>.<span class="pl-s1">org</span><span class="pl-c1">/</span><span class="pl-s1">stable</span><span class="pl-c1">/</span><span class="pl-s1">gallery</span><span class="pl-c1">/</span><span class="pl-s1">event_handling</span><span class="pl-c1">/</span><span class="pl-s1">keypress_demo</span>.<span class="pl-s1">html</span>?<span class="pl-s1">highlight</span><span class="pl-c1">=</span><span class="pl-s1">key_press_event</span>) <span class="pl-c1">in</span> <span class="pl-s1">to</span> <span class="pl-s1">a</span> <span class="pl-s1">file</span>.
<span class="pl-c1">4.</span> <span class="pl-v">Run</span> <span class="pl-s1">it</span>.
<span class="pl-c1">5.</span> <span class="pl-v">Press</span> <span class="pl-s1">some</span> <span class="pl-s1">keys</span>.
<span class="pl-c1">5.</span> <span class="pl-v">Note</span> <span class="pl-s1">stdout</span>.</pre></div>
<h3 dir="auto">Actual outcome</h3>
<p dir="auto">Stdout will be empty.</p>
<h3 dir="auto">Expected outcome</h3>
<p dir="auto">Stdout should say things like:</p>
<p dir="auto">press a<br>
press a<br>
press a<br>
press a<br>
press a<br>
press a<br>
press b<br>
press c<br>
press d<br>
press e</p>
<h3 dir="auto">Additional information</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Operating system</h3>
<p dir="auto">Windows</p>
<h3 dir="auto">Matplotlib Version</h3>
<p dir="auto">Any I've tested from 3.3.0 up to 3.5.1</p>
<h3 dir="auto">Matplotlib Backend</h3>
<p dir="auto">TkAgg</p>
<h3 dir="auto">Python version</h3>
<p dir="auto">3.9.9</p>
<h3 dir="auto">Jupyter version</h3>
<p dir="auto">n/a</p>
<h3 dir="auto">Installation</h3>
<p dir="auto">pip</p>
<h3 dir="auto">Bug summary</h3>
<p dir="auto">mpl with py3.10.1 - Interactive figures - Constrain pan/zoom to x/y axis not work</p>
<h3 dir="auto">Code for reproduction</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Simple Plot

https://matplotlib.org/stable/gallery/lines_bars_and_markers/simple_plot.html"><pre class="notranslate"><span class="pl-v">Simple</span> <span class="pl-v">Plot</span>

<span class="pl-s1">https</span>:<span class="pl-c1">//</span><span class="pl-s1">matplotlib</span>.<span class="pl-s1">org</span><span class="pl-c1">/</span><span class="pl-s1">stable</span><span class="pl-c1">/</span><span class="pl-s1">gallery</span><span class="pl-c1">/</span><span class="pl-s1">lines_bars_and_markers</span><span class="pl-c1">/</span><span class="pl-s1">simple_plot</span>.<span class="pl-s1">html</span></pre></div>
<h3 dir="auto">Actual outcome</h3>
<p dir="auto">Interactive figures - Constrain pan/zoom to x/y axis not work</p>
<p dir="auto">Despite the key being pressed, both axes change</p>
<h3 dir="auto">Expected outcome</h3>
<p dir="auto">i expect the functionality:</p>
<p dir="auto">Navigation keyboard shortcuts</p>
<p dir="auto"><a href="https://matplotlib.org/stable/users/explain/interactive.html" rel="nofollow">https://matplotlib.org/stable/users/explain/interactive.html</a></p>
<p dir="auto">Constrain pan/zoom to x axis  -  hold x when panning/zooming with mouse<br>
Constrain pan/zoom to y axis  -  hold y when panning/zooming with mouse</p>
<h3 dir="auto">Additional information</h3>
<p dir="auto">I've tested a few versions:</p>
<p dir="auto">py 3.8 + mpl 3.4.1 and 3.5.1  o.k.<br>
py 3.9 + mpl 3.4.1 and 3.5.1  o.k.</p>
<p dir="auto">but:</p>
<p dir="auto">py 3.10.1 + mpl 3.4.1 and 3.5.1 --&gt; Constrain pan/zoom  only to x or y axis NOT WORK !</p>
<p dir="auto">What is the reason?</p>
<p dir="auto">Thank you</p>
<h3 dir="auto">Operating system</h3>
<p dir="auto">Win 10</p>
<h3 dir="auto">Matplotlib Version</h3>
<p dir="auto">different 3.4.1 ... 3.5.1</p>
<h3 dir="auto">Matplotlib Backend</h3>
<p dir="auto">TkAgg</p>
<h3 dir="auto">Python version</h3>
<p dir="auto">Python 3.10.1</p>
<h3 dir="auto">Jupyter version</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Installation</h3>
<p dir="auto">pip</p>