Solved

Utility to display keyboard key codes when I press keys

Posted on 2003-10-21
4
774 Views
Last Modified: 2012-06-27
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
Comment
Question by:flakrat
  • 2
4 Comments
 
LVL 22

Expert Comment

by:cookre
ID: 9595973
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
 
LVL 22

Accepted Solution

by:
cookre earned 50 total points
ID: 9596099
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
 
LVL 5

Expert Comment

by:fantasy1001
ID: 9596560
This is the Visual Basic one:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    MsgBox "Key Pressed: " & KeyCode
End Sub
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9597701
if you need in any other languages let me know
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question