Virtual Key Code Constant from decimal value

44 Views Asked by At

I'm currently building a function that detects keyboard and mouse events using Windows Hooks and I'd like to use as minimum code as possible.

I've seen some solutions that as receiving the code from vkCode, checks it with a switch case as the example behind:

switch(vkCode)
{
   case 0x10:                       
      std::cout << "The constant is: VK_SHIFT\n"; 
   break; 
}

But what I'd like to do is reversing the "std:cout << vkCode;" code line that returns me the decimal code of the key with a function that entering with the vkCode as parameter returns me the Virtual Key Code Constant as it follows:

CODE: std::cout << vkConstName(0x10);

ANSWER: $VK_SHIFT

CODE: std::cout << vkConstName(0x10);

ANSWER: $VK_SHIFT

My reference material is: https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes;

0

There are 0 best solutions below