Thread: Reading Keys

  1. #1
    Deleting... VOX's Avatar
    Join Date
    Oct 2004
    Location
    VA
    Posts
    94

    Reading Keys

    I am using a switch case statement in C to detect what the user presses at the keyboard. I've got it to work with everything except the arrow keys and the number-pad because I don't know their ASCII codes (if any). Here is an example

    Code:
    #include <stdio.h>
    #include <conio.h>
    
    void main()
    {
            char key;
            
            key=toupper(getch());
            switch(key)
            {
                    case 32:
                            printf("You hit the spacebar!");
                            getchar();
                            break;
            }
    }
    what would I put into "blah"
    case "blah":
    for arrow keys?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Did you look at the FAQ? I bet you didn't.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Deleting... VOX's Avatar
    Join Date
    Oct 2004
    Location
    VA
    Posts
    94
    Boy you and others on this site are a real pain in the arse. If you don't have something helpful to say don't say it.

    WRONG-Did you look at the FAQ? I bet you didn't.

    RIGHT-Try looking at the FAQ board under "Directional Keys - Useing in Console"
    In blah you can use these codes-

    75--Left
    77--Right
    72--Up
    80--Down

    And not listed in that thread is this

    71--Up Left
    73--Up Right
    79--Down Left
    81--Down Right

    VOX.
    Last edited by VOX; 11-26-2004 at 07:38 PM.

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    What are you talking about? Try using complete sentences for once. Let's dissect this thread, shall we?
    I am using a switch case statement in C to detect what the user presses at the keyboard. I've got it to work with everything except the arrow keys and the number-pad because I don't know their ASCII codes (if any). Here is an example
    Here you say you don't know their ascii codes. You don't say you've looked at the FAQ. You don't say you've done a forum search. You don't say you've done a google search. All you say is you don't know them.

    To which I reply:
    Did you look at the FAQ? I bet you didn't.
    Why on earth would I assume that? Oh, how about because NO ONE reads the FAQ. Since you didn't say anything about the FAQ being wrong, as you say it is, one can assume safely that you didn't read it.

    Because at the time, if you had read it, you would have told us it was wrong. Wouldn't you?

    No. Of course you wouldn't. Because you, like everyone else, expect us to be I am sillyI am sillyI am sillyI am sillyING PSYCHIC and to know what you've tried already.

    Enjoy your candy.

    Quzah.
    Last edited by quzah; 11-26-2004 at 05:02 PM. Reason: Typo. Wouldn't want them to complain about that too, would we?
    Hope is the first step on the road to disappointment.

  5. #5
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Boy you and others on this sight
    sight:
    The ability to see.
    The act or fact of seeing: hoping for a sight of land; caught sight of a rare bird.
    Field of vision.
    The foreseeable future; prospect: no solution in sight.
    Mental perception or consideration: We lost sight of the purpose of our visit.
    Something seen; a view.
    Something worth seeing; a spectacle: the sights of London.
    Informal. Something unsightly: Your hair is a sight.
    A device used to assist aim by guiding the eye, as on a firearm or surveying instrument.
    An aim or observation taken with such a device.
    An opportunity to observe or inspect.
    Upper Southern U.S. A large number or quantity: A sight of people were there.
    site
    The place where a structure or group of structures was, is, or is to be located: a good site for the school.
    The place or setting of something: a historic site; a job site.
    A website.
    are a real pain in the arse.
    Thank you

  6. #6
    Deleting... VOX's Avatar
    Join Date
    Oct 2004
    Location
    VA
    Posts
    94
    Quzah, I never said anything about the FAQ being wrong. If you had read my reply at all you would have figured out that I had read it to get the info I posted.

    WRONG-Did you look at the FAQ? I bet you didn't.

    RIGHT-Try looking at the FAQ board under "Directional Keys - Useing in Console"

    Tells you that you should be a little more helpful, as it will make people like you better in the long run. Plus most of that thread was in C++ anyway.

    Let's compare your helpful reply to your "prove me wrong" reply. Hmm, 2 sentences compared to 16 and 2 quotes. Boy that first reply took, what, 10 seconds or less to make? And the second, 10 minutes? Maybe if you spent as much time helping out as you do proving me wrong, everyone would benefit more.

  7. #7
    We're volunteers. We take time out of busy lives to answer questions, and at times we're overwhelmed with them. So we filter ruthlessly. In particular, we throw away questions from people who appear to be losers in order to spend our question-answering time more efficiently, on winners.

    If you find this attitude obnoxious, condescending, or arrogant, check your assumptions. We're not asking you to genuflect to us — in fact, most of us would love nothing more than to deal with you as an equal and welcome you into our culture, if you put in the effort required to make that possible. But it's simply not efficient for us to try to help people who are not willing to help themselves.

    If you decide to come to us for help, you don't want to be one of the losers. You don't want to seem like one, either. The best way to get a rapid and responsive answer is to ask it like a person with smarts, confidence, and clues who just happens to need help on one particular problem.

    It isn't useful to insist you've been personally insulted when someone comments that one of your claims was wrong, or that his views differ. Those are loser attitudes. Remember: When a member tells you that you've screwed up, he's acting out of concern for (1) you and (2) the community.

    If you can't manage to be grateful, at least have a little dignity, don't whine, and don't expect to be treated like a fragile doll just because you're a newcomer with a theatrically hypersensitive soul and delusions of entitlement. Complaining is the way to really screw up.


    - Stack Overflow
    Segmentation Fault: I am an error in which a running program attempts to access memory not allocated to it and core dumps with a segmentation violation error. This is often caused by improper usage of pointers, attempts to access a non-existent or read-only physical memory address, re-use of memory if freed within the same scope, de-referencing a null pointer, or (in C) inadvertently using a non-pointer variable as a pointer.

  8. #8
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by VOX
    Quzah, I never said anything about the FAQ being wrong. If you had read my reply at all you would have figured out that I had read it to get the info I posted.

    WRONG-Did you look at the FAQ? I bet you didn't.

    RIGHT-Try looking at the FAQ board under "Directional Keys - Useing in Console"
    Yeah, I read your reply and didn't know what the I am sillyI am sillyI am sillyI am silly you were trying to say. What does "RIGHT-Try looking at the FAQ board under..." mean?

    Try reading THE FAQ. Not the FAQ board. THE FAQ.

    I mean really, form complete sentences not I am sillyI am sillyI am sillyI am silly like "WRONG-Did you look..." and "RIGHT-Try looking at..." because none of that means anything. USE COMPLETE SENTENCES.

    Quzah.
    Hope is the first step on the road to disappointment.

  9. #9
    Deleting... VOX's Avatar
    Join Date
    Oct 2004
    Location
    VA
    Posts
    94
    Whatever. Let's just drop this. I have the info, whether I got it from you or not isn't relevant. Both of our views on who is right or wrong are pointless. Although not everything has to be in complete sentences for someone to understand it. That's for english teachers.
    Stack Overflow, I now see your point.

  10. #10
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    On this forum ALL questions should be in the form of complete sentances. Its not for english teachers, its for aid in communications.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading words and analyzing words from file
    By desmond5 in forum C Programming
    Replies: 7
    Last Post: 02-26-2008, 03:51 PM
  2. Replies: 2
    Last Post: 01-28-2008, 03:07 AM
  3. help with reading from stream
    By movl0x1 in forum C Programming
    Replies: 7
    Last Post: 05-31-2007, 10:36 PM
  4. Fun with reading hex
    By dpro in forum C++ Programming
    Replies: 7
    Last Post: 02-17-2006, 06:41 PM
  5. reading file word by word
    By 98holb in forum C Programming
    Replies: 2
    Last Post: 01-25-2006, 05:49 PM