Skip to content

Planet-Source-Code/josh-nixon-detecting-dos-arrow-keys__3-5339

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

[Detecting Dos Arrow Keys]

Description

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

More Info

Submitted On
By Josh Nixon
Level Beginner
User Rating 4.7 (42 globes from 9 users)
Compatibility C++ (general)
Category Coding Standards
World C / C++
Archive File

API Declarations

#include <iostream.h> //cout
#include <conio.h> //kbhit() getch()

Source Code

#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;
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published