#include #include #include typedef unsigned char byte; int pushed, released, count, myQuit; char mykey, mykey2; void interrupt (*OldClockHandler)(void); void interrupt (*OldProcessKey)(void); void interrupt CountClock(void) { if (pushed==1) { count++; } }; void interrupt ProcessKey(void) { asm { in al,60h; mov mykey,al; } pushed=1; if ((mykey2+0x80)==mykey) { pushed=0; released=1; } mykey2=mykey; OldProcessKey(); } void main() { OldClockHandler = getvect(0x1c); setvect(0x1c, CountClock); OldProcessKey = getvect(0x9); setvect(0x9, ProcessKey); count=pushed=released=myQuit=0; clrscr(); do { if ((released==1)) { gotoxy(1,1); printf("Delka stisku klavesy: %d ms ", count*55); count=0; released=0; pushed=0; } if (kbhit()) { if (getch()==27) myQuit=1; } } while (!myQuit); setvect(0x1c, OldClockHandler); setvect(0x9, OldProcessKey); }