title: Comparing a KeyCode object to string in python
body: <p>I'm trying to trigger functions on key presses in python. I'm using the pynput library's listen function, which returns a Keycode object.
  I've tried casting the object to string but the following code still returns the following output (when pressing the 'a' key):</p>
  
  <pre><code>def on_press(key):
      mod = str(key)
      print(mod)
      print(type(mod))
      print(mod=='a')
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>'a'
  &lt; class 'str'&gt;
  False
  </code></pre>