Thread: Better ANSI keyboard handling?

  1. #1
    Registered User
    Join Date
    Dec 2007

    Better ANSI keyboard handling?


    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?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    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).

    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, 04: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, 11:14 AM
  5. ANSI Escape Sequences OR Scan of keyboard
    By Samppa in forum Linux Programming
    Replies: 3
    Last Post: 10-24-2001, 12:15 PM