Better ANSI keyboard handling?

This is a discussion on Better ANSI keyboard handling? within the C Programming forums, part of the General Programming Boards category; Hello, I am writing a command prompt program in C but am having issues with the current i/o functions that ...

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    51

    Better ANSI keyboard handling?

    Hello,

    I am writing a command prompt program in C but am having issues with the current i/o functions that ANSI C provides. I am currently using gets() and scanf(), but they can't take individual characters. For example:

    If the user presses the up button, I would like to know, instead of waiting for the enter button to get pressed. Is there an ANSI function out there to do something like this?

    In other words, tell me whats going on one key at a time?
    Thanks.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    No, the ANSI standard doesn't have any functions to do that sort of thing. It is system dependent. You can find some of the system specific functions to deal with keyboard/console input in the FAQ under "how do I get user input without waiting for enter".

    Or you can use curses (e.g. ncurses in linux or pdcurses for windows).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. event handling is serialized in MS Visual Studio C++ 2005 ??
    By mynickmynick in forum Windows Programming
    Replies: 3
    Last Post: 08-07-2008, 05:47 AM
  2. Signal Handling - Are they part of ANSI C?
    By Stanley S in forum C Programming
    Replies: 3
    Last Post: 12-21-2005, 07:49 AM
  3. keyboard error handling
    By xelitex in forum C++ Programming
    Replies: 7
    Last Post: 12-18-2004, 02:53 PM
  4. Handling keyboard input in a dialog procedure.
    By ganonl in forum Windows Programming
    Replies: 2
    Last Post: 08-23-2003, 12:14 PM
  5. ANSI Escape Sequences OR Scan of keyboard
    By Samppa in forum Linux Programming
    Replies: 3
    Last Post: 10-24-2001, 01:15 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21