Indeed. Are you using Windows or Linux?

If Windows, I know you could set a keyboard hook using the API, but most people just use DirectInput I think...