Thread: Keyboard Input

  1. #1
    Registered User
    Join Date
    Mar 2002

    Keyboard Input

    i'm reading in characters from the keyboard and i'm wanting to check if the character entered is a backspace and if it is i want to output the ASCII value 08.

    i have this snippet of my code:

    c = fgetc(stdin);

    if (c== '\127')

    I'm not sure if this is right as it doesn't seem to be working

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Unfortunately, with buffered input you can't read a backspace keypress with fgetc. You'll need to use a raw input function such as getch:
    #include <stdio.h>
    #include <conio.h>
    int main ( void )
      int c;
      c = getch();
      if ( c == '\b' )
        printf ( "Backspace pressed\n" );
      return 0;
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help using inline assembly for keyboard input
    By sleventeen in forum C Programming
    Replies: 7
    Last Post: 05-10-2009, 01:31 AM
  2. Keyboard Input
    By CaliJoe in forum C++ Programming
    Replies: 3
    Last Post: 05-08-2009, 09:51 AM
  3. Keyboard input in a Dialog
    By ksarkar in forum C++ Programming
    Replies: 1
    Last Post: 05-20-2005, 05:39 AM
  4. Intercepting keyboard input
    By EvBladeRunnervE in forum Windows Programming
    Replies: 3
    Last Post: 01-08-2004, 09:03 AM
  5. FAQ Keyboard Input ? (C++)
    By Malikive in forum FAQ Board
    Replies: 6
    Last Post: 11-07-2001, 09:30 PM