Solved

Utility to display keyboard key codes when I press keys

Posted on 2003-10-21
4
745 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
if you need in any other languages let me know
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
A short article about a problem I had getting the GPS LocationListener working.
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…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

743 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

18 Experts available now in Live!

Get 1:1 Help Now