def METHOD_NAME(self, event: QKeyEvent) -> bool:
    """Handle a key press/release event.
    Args:
        event: The QEvent which is about to be delivered.
    Return:
        True if the event should be filtered, False if it's passed through.
    """
    active_window = objects.qapp.activeWindow()
    if active_window not in objreg.window_registry.values():
        # Some other window (print dialog, etc.) is focused so we pass the
        # event through.
        return False
    try:
        man = modeman.instance('current')
        return man.handle_event(event)
    except objreg.RegistryUnavailableError:
        # No window available yet, or not a MainWindow
        return False