title: How to detect user input (such as a command - ctrl+shift+k) in Python on Mac?
body: <p>So I'm building this joke program in Python. Basically, what it is and does is it is an app disguised as a game, and when opened, the headphone port is disabled, the audio output is set to computer speakers, volume is set to max, and it says 'gamer alert' many times. The problem I am having is that there is no way to stop it; even if you delete the application while it is running still won't do anything. I need a method of detecting a keyboard shortcut made to stop it. It needs to be compatible with Mac.
  Note: if you want to test, you can set it to a lower volume by changing 100 to something around 20 or 30.</p>
  
  <p>I've tried using PyGame, Tkinter, Pynput, Getch, etc. all didn't work. I'm not too sure if it's because I'm not using them right, or if they won't work at all with what I'm trying to do.</p>
  
  <pre><code>import os
  
  while True:
      os.system('SwitchAudioSource -s "Built-in Output"')
      os.system("osascript -e 'set volume output volume 100'")
      os.system("say gamer alert")
  </code></pre>
  
  <p>I have gotten a few error messages with some of the modules I mentioned above, but otherwise no error messages. The voice might stop after one iteration. Without this kill feature, it works beautifully.</p>