title: QWidget cannot catch ESCAPE, BACKSPACE or C-x key press events
body: <p>I am catching key press events by overriding the <code>KeyPressEvent</code> method of my class, inheriting from <code>QWidget</code>, but I cannot see key <em>press</em> events for the ESCAPE and BACKSPACE keys, as well as <code>C-x</code> or again <code>C-c</code>. I can see key <em>release</em> events though. Who catches them ? </p>
  
  <pre><code>class KeyCaptureWidget(QWidget):
      # init…
  
      def keyPressEvent(self, event):
          key = event.key()
          logging.info("key press: {}".format(key))
  
      def keyReleaseEvent(self, event):
          key_code = event.key()
          logging.info("key release: {}".format(key_code))
  </code></pre>
  
  <p>The difference between <code>C-x</code> and say <code>C-b</code> is the following:</p>
  
  <ul>
  <li>pressing <code>C-b</code> prints: control is pressed, b is pressed, b is released, control is released.</li>
  <li>pressing <code>C-x</code> prints: control is pressed, [nothing], x is released, control is released.</li>
  </ul>
  
  <p>In my QWidget, I use a QVBoxLayout to which I put two QWebEngine views. I tried to override the key press method of the QWebEngineView, but they don't seem to catch anything (and this is the behaviour I expected).</p>
  
  <pre><code>    def __init__(self):
          self.qtwindow = KeyCaptureWidget()
  
          self.layout = QVBoxLayout()
          self.view1 = QWebEngineView()  # or a custom one to override keyPressEvent
          # self.view2 = the same
  
          self.layout.addWidget(self.view1)
          self.layout.addWidget(self.view2)
          self.qtwindow.setLayout(self.layout)
          self.qtwindow.show()
  </code></pre>
  
  <p>I tried to catch these with <strong>event filters</strong> on my QWidget class but again, no luck: I see only a key release for ESC or BACKSPACE.</p>
  
  <pre><code>    def __init__(self):
          super().__init__()
          self.installEventFilter(self)
  
      def eventFilter(self, source, event):
          logging.info("event filter: {}".format(event))
          if event.type() == QEvent.KeyPress:
              logging.info(" event filter key PRESS")
          if event.type() == QEvent.KeyRelease:
              logging.info(" event filter key RELEASE")
          return True
  </code></pre>
  
  <p>How can I catch them ? Thank you.</p>