If you are using Windows then use the Win32 API function GetAsyncKeyState(); or if you know Win32API well then use WM_KEYDOWN message. Though assuming you would not want to do multithreading and all, your best bet is GetAsyncKeyState();
GetAsyncKeyState();
WM_KEYDOWN