Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 800
  • Last Modified:

Utility to display keyboard key codes when I press keys

Howdy,

Does anyone know of a utility that will display the code that is transmitted by the keyboard when a key is pressed?

Thanks,

Mike
0
flakrat
Asked:
flakrat
  • 2
1 Solution
 
cookreCommented:
Not off-hand, but it would be easy to write.  Are you looking for code in any particular language, or just an executable?

Which OS?

0
 
cookreCommented:
FWIW, here's an MS C console app that does just that:

#include "stdafx.h"
#include <conio.h>
#include <stdio.h>
char c;

int main(int argc, char* argv[])
{
c=0;
// Drain keyboard buff
while (_kbhit()) _getch();

// Keep going until = is hit
while (c!='=')
      {
      // Note that CTRL-C (3) is not caught here
      if (_kbhit())
         {
         c=_getch();
         if (c==0 || c==0xe0)
            {
            // Special key
            c=_getch();
            printf("* %d\n",c);
            }
         else
            {
            printf("%d\n",c);
            }
         }
      }
return 0;
}

0
 
fantasy1001Commented:
This is the Visual Basic one:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    MsgBox "Key Pressed: " & KeyCode
End Sub
0
 
bhagyeshtCommented:
if you need in any other languages let me know
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now