Personal tools
Document Actions

lesson2b.cpp

by aullmj — last modified 2009-01-26 18:59

conio demo for lesson2

Click here to get the file

Size 1.4 kB - File type text/x-c++src

File contents

//Simple and more developed conio demos (get keystroke)
//Mark Aull, 2008

/*#include <stdio.h>
#include <conio.h>

void main(void)
{//main function
	int a=0;
	while(1)
	{//while loop (until esc)
		a=getch();				//get character from keyboard
		printf("%10d %5c\n",a,a);//display character as integer and character
	}//end while loop
}//end main*/

#include <stdio.h>
#include <conio.h>

void main(void)
{//main function
	int a=0;
	while(a!=27)
	{//while loop (until esc)
		a=getch();
		printf("%10d %5c\n",a,a);

		if (a==224||a==0)
		{//control key
			a=getch();
			printf("command: %10d %5c\n",a,a);
			if (a=='H')
				printf("up\n");
			else if(a=='M')
				printf("right\n");
			else if(a=='K')
				printf("left\n");
			else if(a=='P')
				printf("down\n");
			else if(a>58&&a<69)
				printf("F%d\n",a-58);
			else if(a>=133&&a<=134)
				printf("F%d\n",a-133+11);
			else if(a=='O')
				printf("end\n");
			else if(a=='Q')
				printf("pgdn\n");
			else if(a=='S')
				printf("del\n");
			else if(a=='R')
				printf("ins\n");
			else if(a=='G')
				printf("home\n");
			else if(a=='I')
				printf("pgup\n");
			else if(a>83&&a<94)
				printf("shift F%d\n",a-83);
			else if(a>=94&&a<104)
				printf("ctrl F%d\n",a-93);
			else if(a>=104&&a<114)
				printf("alt F%d\n",a-103);
		}//end control key
	}//end while
}//end main function//*/
Related content