title: keyboard.hook_key() stops responding to presses after some kind of error. Only after compiling to .exe
body: <p>The problem only appears after compiling to .exe: in line <code>keyboard.hook_key ('f7', TranslateAll, suppress = True)</code> when pressing <em>F7</em> calls the function <code>TranslateAll</code>. Function algorithm:</p>
  <ol>
  <li>Library <code>pyperclip</code> pulls text from the clipboard</li>
  <li>Library <code>googletrans</code> translates text</li>
  <li><code>pyperclip</code> inserts the translated text into clipboard</li>
  </ol>
  <p>Everything works fine, however, after compiling to .exe, after 10 function calls, <code>keyboard.hook_key()</code> stops responding.</p>
  <p>I've tried reassigning <em>F7</em> in <code>keyboard.hook_key ()</code> on error, but that didn't work either.</p>
  <p><strong>What could be the problem?</strong></p>
  <p><strong>The problematic part of the code:</strong> (You can try running it to see it work and then using pyinstaller &quot;NameOfCode.py&quot; to see the problem I described)</p>
  <pre><code>from PyQt5.QtWidgets import *
  from PyQt5.QtCore import QSize
  from googletrans import Translator
  import keyboard
  import googletrans
  import pyperclip
  
  count = 0                         #function operation counter
  
  TranslateAll_count = 0            #variable, for single
                                    #triggering a function when a button is pressed
  
  def TranslateAll(event):
      global TranslateAll_count
      global count
      TranslateAll_count += 1
      if TranslateAll_count != 2:
  
          #main algorithm 
  
          translator = Translator()
  
          data = pyperclip.paste()
  
          result = translator.translate(data, dest='ru')
  
          pyperclip.copy(result.text)
  
          TranslateAll_count = 1
          count += 1
          print(f'Actuation №{count}\n')
  
  
  class MainWindow(QMainWindow):
      def __init__(self):
  
          QMainWindow.__init__(self)
          self.setFixedSize(QSize(480, 180))
          self.setWindowTitle(&quot;test&quot;)
  
          #binding F7 to a function TranslateAll
          keyboard.hook_key('f7', TranslateAll, suppress=True)
  
  
  if __name__ == &quot;__main__&quot;:
      import sys
   
      app = QApplication(sys.argv)
      mw = MainWindow()
      mw.show()
      sys.exit(app.exec())
  </code></pre>
  <p><strong>Output when running a .py file:</strong></p>
  <pre><code>Actuation №1
  Actuation №2
  Actuation №3
  Actuation №4
  #until the user finishes work
  </code></pre>
  <p><strong>Output when running .exe file:</strong></p>
  <pre><code>#7 Actuations
  Actuation №8
  #the function stops being called
  </code></pre>