Advertisement
2_2002-2004 Coding Standards #128118

[Detecting Dos Arrow Keys]

This will just show how a person might use the arrow keys in DOS.

AI

KI-Zusammenfassung: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Quellcode
original-source
#include <iostream.h>
#include <conio.h> //kbhit() getch()
//Getch()= retrieves the char and wait for it to be pressed
//kbhit() = keeps processing commands while you hit
//These are used for arrow keys since getch() does not return extended char
const char CPPKEYUP = 72;
const char CPPKEYLEFT = 75;
const char CPPKEYRIGHT = 77;
const char CPPKEYDOWN = 80;
int main()
{
 char Arrow = 0;
 Arrow = kbhit();
 while(Arrow !=27)
  {
  Arrow = getch();
   switch(Arrow)
   {
  case CPPKEYUP:
    cout<<" UP "
  break; 
  case CPPKEYDOWN:
    cout<<" DOWN "
  break;
  case CPPKEYLEFT:
    cout<<" LEFT "
   break;
 case CPPKEYRIGHT:
    cout<<" RIGHT "
   break;
 }
}
return 0;
}
Originalkommentare (3)
Wiederhergestellt von der Wayback Machine