1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| // testclavier.cpp : Defines the entry point for the console application.
//
#include <stdafx.h>
#include <stdio.h>
#include <conio.h>
void main(void)
{
int ch, scan;
do {
ch = getch(); /* 1st getch() gets ASCII code */
printf("Character is %d\n", ch);
if (ch == 0x00 || ch == 0XE0) { /* if extended key */
scan = getch(); /* 2nd getch() gets "scan code" */
if (scan==72)
{
printf("haut\n");
}
if (scan==80)
{
printf("bas\n");
}
if (scan==75)
{
printf("gauche\n");
}
if (scan==77)
{
printf("droite\n");
}
else
{
}
printf("\tExtended character: scan is %d\n", scan);
}
} while (ch != 27); /* exit loop on ESC */
} |
Partager