Note to self and world: PyQt PyKDE discovering state of num scroll and caps lock keys
maj 21, 2010
If you are looking for a Qt only solution, I am sorry, but that is not available (according to a bug report on qt which I now can’t find). If you are against using the KDE libraries, I am pretty sure you can do it with SDL.
import sys from PyKDE4 import kdeui from PyQt4.QtGui import QApplication from PyQt4.QtCore import Qt app = QApplication(sys.argv) a = kdeui.KModifierKeyInfo() print(a.isKeyLocked(Qt.Key_NumLock))
The keys are in the PyQt4.QtCore.Qt class (and the names of the keys can be found in the qt docs).