Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,385 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,182 people online right now. Registration is fast and FREE... Join Now!




Key Parameters

 
Reply to this topicStart new topic

Key Parameters

dvon2008
post 22 Aug, 2008 - 03:26 PM
Post #1


New D.I.C Head

*
Joined: 27 Nov, 2007
Posts: 18


My Contributions


I am looking for the key parameters. I know the escape button is 27 but i am needing the other ones so i can add more key press actions.
User is offlineProfile CardPM

Go to the top of the page

Whizzy
post 22 Aug, 2008 - 06:59 PM
Post #2


Unregistered




Are you talking about ASCII key codes?

To display the ascii key codes, try something like this.

cpp
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
for(int a = 1; a<= 255; a++)
{
char b = a;
cout<<a <<": "<<b<<", ";
}

system("PAUSE");
return EXIT_SUCCESS;
}


Go to the top of the page

NickDMax
post 22 Aug, 2008 - 08:35 PM
Post #3


2B||!2B

Group Icon
Joined: 18 Feb, 2007
Posts: 2,857



Thanked 47 times

Dream Kudos: 550
My Contributions


www.asciitable.com
User is offlineProfile CardPM

Go to the top of the page

NickDMax
post 22 Aug, 2008 - 08:43 PM
Post #4


2B||!2B

Group Icon
Joined: 18 Feb, 2007
Posts: 2,857



Thanked 47 times

Dream Kudos: 550
My Contributions


Another fun program is this (may not work on all compilers since it requires conio.h):
CODE
#include <cstdio>
#include <conio.h>
using namespace std;

int main() {
    char c;
    while ((c = getch())!=27) {
        printf("Char %c, %3d, 0x%2X\n" , c,  c, c);
    }
    return 0;
}
User is offlineProfile CardPM

Go to the top of the page

gabehabe
post 23 Aug, 2008 - 03:05 AM
Post #5


Working Girl.

Group Icon
Joined: 6 Feb, 2008
Posts: 5,402



Thanked 94 times

Dream Kudos: 2625

Expert In: Dingleberries

My Contributions


To expand on Whizzy's concept a little, you don't even need to create a character variable. You can simple convert it when it needs to be converted, like so:
cpp
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
for(int a = 0; a< 255; a++)
cout<<a <<": "<< static_cast <char> (a) << endl;
// could also be:
// cout << a << ": " << (char)a << endl;

cin.get ();
return EXIT_SUCCESS;
}

smile.gif
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/22/08 06:42AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month