<div dir="ltr"><div><div><div><div><div>In QVTKRenderWindowInteractor, keyPressEvent and keyReleaseEvent are implemented as follows:<br><br>Â Â Â def keyPressEvent(self, ev):<br>Â Â Â Â Â Â Â ctrl, shift = self._GetCtrlShift(ev)<br>Â Â Â Â Â Â Â if ev.key() < 256:<br>Â Â Â Â Â Â Â Â Â Â Â key = str(ev.text())<br>Â Â Â Â Â Â Â else:<br>Â Â Â Â Â Â Â Â Â Â Â key = chr(0)<br><br>Â Â Â Â Â Â Â keySym = _qt_key_to_key_sym(ev.key())<br>Â Â Â Â Â Â Â if shift and len(keySym) == 1 and keySym.isalpha():<br>Â Â Â Â Â Â Â Â Â Â Â keySym = keySym.upper()<br><br>Â Â Â Â Â Â Â self._Iren.SetEventInformationFlipY(self.__saveX, self.__saveY,<br>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ctrl, shift, key, 0, keySym)<br>Â Â Â Â Â Â Â self._Iren.KeyPressEvent()<br>Â Â Â Â Â Â Â self._Iren.CharEvent()<br><br>Â Â Â def keyReleaseEvent(self, ev):<br>Â Â Â Â Â Â Â ctrl, shift = self._GetCtrlShift(ev)<br>Â Â Â Â Â Â Â if ev.key() < 256:<br>Â Â Â Â Â Â Â Â Â Â Â key = chr(ev.key())<br>Â Â Â Â Â Â Â else:<br>Â Â Â Â Â Â Â Â Â Â Â key = chr(0)<br><br>Â Â Â Â Â Â Â self._Iren.SetEventInformationFlipY(self.__saveX, self.__saveY,<br>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ctrl, shift, key, 0, None)<br>Â Â Â Â Â Â Â self._Iren.KeyReleaseEvent()<br><br></div>Notice how in keyPressEvent, key (the keycode passed to SetEventInformationFlipY) is constructed from str(ev.text()), which I find strange. Why use the .text() of the Qt event and not the keycode (.key())? SetEventInformationFlipY seems to expect a char a keycode.<br><br></div>In keyReleaseEvent it is constructed from chr(ev.key()), which I think looks right.<br><br></div>Is there some subtility I'm missing here, or is this just a mistake?<br><br></div>Thanks in advance,<br></div>Elvis<br></div>