Is there a way to trigger a QShortcut on a button release?

556 views Asked by At

I currently have this, which functions as expected, running on keyboard button press.

# QWidget == widget shortcut is assigned to

shortcut = QtWidgets.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_M), QWidget)
shortcut.setContext(QtCore.Qt.ApplicationShortcut)
shortcut.activated.connect(self.script_to_run)

What I want is for this to instead run on keyboard button release.

Reason being, I want to run one script when the button is pressed and then a separate script when the same button is released.

I have tried a few different things, keyReleaseEvent(), and eventFilter(), but I think by using QShortcut these events become suppressed.

0

There are 0 answers