Is there a way to capture keystrokes in Python and filter out those generated by key repeat?
<p>I'm experimenting with some input methods in Python, and using <code>pynput</code> I have a simple grabber for keys being pressed and released, just like in the docs:</p>

<pre><code>from pynput.keyboard import Key, Listener

def on_press(key):
    print('{0} pressed'.format(
        key))

def on_release(key):
    print('{0} release'.format(
        key))
    if key == Key.esc:
        # Stop listener
        return False

# Collect events until released
with Listener(
        on_press=on_press,
        on_release=on_release) as listener:
    listener.join()
</code></pre>

<p>However, on_press is called regardless of whether the key was generated by a key repeating or just the key being pressed and as far as I can tell, I cannot know which it is.</p>

<p>Is there a way to at know? My target platform is macOS, but this should hopefully work on Windows as well as I may want to port this idea some day.</p>

<p><code>pynput</code> is nice, but I don't mind switching libraries if it means I can get what I need for this to work.</p>