Mine
public text v1 · immutable mask = 0
# map the pretty keyboard event name string to the real AT-SPI constant
type = [Constants.name_to_device_type[name]]
# get an AT-SPI device event controller
dc = registry.getDeviceEventController()
# register for all possible key combos (plain key, key+shift, key+alt, ...)
while mask <= (1 << Accessibility.MODIFIER_NUMLOCK):
dc.registerKeystrokeListener(self._this(), [], mask, type, self.mode)
mask += 1