[Solved] Is there anyway i can detect “~” by using GetAsyncKeyState?


The virtual key code of “~” is VK_OEM_3.

More virtual key codes can be referenced:

https://docs.microsoft.com/en-us/windows/desktop/inputdev/virtual-key-codes

How to use it, please refer to MSDN

A simple example:

#include <Windows.h>
#include <iostream>
using namespace std;

int main()
{
  BOOL OEM_3 = FALSE;
  while (1)
  {
    if (GetAsyncKeyState(VK_OEM_3) < 0 && OEM_3 == false)
    {
      //Press down
      OEM_3 = true;
      cout << "Press down" << endl;
    }
    if (GetAsyncKeyState(VK_OEM_3) >= 0 && OEM_3 == true)
    {
      //Release
      OEM_3 = false;
      cout << "Release" << endl;
    }
  }
  return 0;
}

4

solved Is there anyway i can detect “~” by using GetAsyncKeyState?