Using GetKeyState()

后端 未结 5 1315
花落未央
花落未央 2020-12-10 15:46

I would like to have a boolean event toggle when a key is pressed. Specifically, the \'s\' key. I have been pointed to the function GetKeyState(), which supposedly works und

5条回答
  •  温柔的废话
    2020-12-10 16:19

    I use a global variable bool altgr

    Example:

    void Editor::HandleKey(char car) {
    
        bool shift = false;
        //bool altgr = false;
        bool printable = false;
    
        if (car == 27) SendMessage(hwnd, WM_DESTROY, 0, 0);
    
        if ((GetKeyState(VK_CAPITAL) & 0x0001) == 1) shift = true;
        if ((GetKeyState(VK_SHIFT) & 0x8000) == 0x8000) shift = true;
        // if(GetKeyState(VK_RMENU) & 0x80000000 == 0x80000000) altgr = true;
        if (car == 18) altgr = true; 
    

提交回复
热议问题