Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Register key events when app is minimized



  • Is there a way to register key events when the windows is not in focus / minimized? I know this is possible using :

    if (GetAsyncKeyState(VK_RSHIFT)) {
        //Code here
    }
    

    So when you press Right shift even when the app is minimized it runs the code inside.

    But is there a way to do this in Qt by using QKeyEvent?

    The reason i am not using GetAsyncKeyState is because for some reason it ignores an if statement :

    if (*Condition* == true) {
        if (GetAsyncKeyState(VK_RSHIFT)) {
            //Code here
        }
    }
    

    So as an example in the code above, It already sets the code to true for the GetAsyncKeyState even though the first if statement is false so when the condition of the first if statement is true it already runs the code inside the second if statement because i pressed the key once before no matter when i did it.

    Thanks in advance!


Log in to reply