/**************************************************************** * Name: key * * Synopsis: This program shows ASCII key codes and character* * displayed on the screen. It will also display * * key codes for any key the user presses until * * they press the [Esc] key. * ****************************************************************/ main() { int key, row, column, i, ESC, width; text AMenu[9]; AMenu[0] = " Description of the key.cpl Program"; AMenu[1] = " This program displays all of the character"; AMenu[2] = " codes from 1 through 255. After displaying"; AMenu[3] = " the characters you can press any key and the"; AMenu[4] = " program will display the key's code and"; AMenu[5] = " visible character. You can use this program"; AMenu[6] = " to find the key codes for the function and"; AMenu[7] = " cursor control keys."; AMenu[8] = " Press [Enter] to continue..."; /* Display the program discription in a menu box. */ scroll(0,0,MaxRow_,79,0,1); menu(5,17,16,66,AMenu,1); scroll(0,0,MaxRow_,79,0,1); cursoroff(); /* Set the width of each column in the display. Loop */ /* across the screen and display the column headers. */ width = 6; for(column = 0; (column < 75) and (i < 256); column = column + width) { puts(3,column,"ch #³"); puts(4,column,"ÄÄÄÄÄÅ"); } /* Display the row entries looping down and then across. */ i = 1; for(column = 0; (column < 80) and (i < 256); column = column + width) for(row = 5; (row < 25) and (i < 256); row = row + 1) { puts(row,column,chr(i)+ str(i,4)+ "³"); i = i + 1; } /* Keep getting key strokes and display the character code */ /* until the user presses the escape key, which is code 27. */ ESC = 27; puts(0,0,"Press any key for display, or [Esc] to exit."); while((key = getkey()) <> ESC) puts(1,0,"Key = "+str(key,6,0,',')+' "'+chr(key)+'" '); cursoron(); }