Solved

Utility to display keyboard key codes when I press keys

Posted on 2003-10-21
4
758 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
countHi challenge 25 100
listing all functions in JavaScript 19 179
creating threads in delphi 1 84
Advice in Xamarin 21 57
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

867 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now