C++ Course Listing

 

Example Code:

ASCII Key Values

 

// keys.cpp : Defines the entry point for the console application.
// Simple console program that prints to screen the ASCII code of keys, except the ESC key.

//Matthew Martin, 2004

#include "stdafx.h"
#include "conio.h"


int main(int argc, char* argv[])
{
unsigned int c;

cprintf ("\n\rpress a key (ESC exits) \n\r");

do
{
c=getch();
if (!c)
c=256+getch();
cprintf ("%d \n\r", c);
}
while (c!=27); // 27==ESC

return 0;
}

 

by Matthew Martin

top of page