Thread: Detect Ctrl+anykey (e.g. Ctrl+A)

  1. #1
    Registered User Tiago's Avatar
    Join Date
    Oct 2009
    Location
    Lisbon, Portugal
    Posts
    28

    Detect Ctrl+anykey (e.g. Ctrl+A)

    Hi,

    How can i detect when Ctrl+anykey is pressed simultaneously???

    My program should exit when I write "exit" or when Ctrl+D is pressed... I know that normally Ctrl+D should kill a program running in a terminal (e.g. Konsole) but due to an if-else chain, Ctrl+D is recognized by the program, as an error.

    ty...
    Last edited by Tiago; 10-29-2009 at 07:07 AM.

  2. #2
    Registered User
    Join Date
    Oct 2009
    Location
    Indonesia
    Posts
    68
    All I know that, there is still have another ASCII code after 256,,
    example..
    256+15 is for SHIFT TAB

    256+73 is for Page Up.. etc,,
    but I don't remember for CTRL..
    so you can use if, and getch

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Well, Ctrl-D is EOF on unixy systems, and there may not be anything you can do about that. On the plus side, that makes it easy to check for, if that's the kind of system you are on.

  4. #4
    Registered User
    Join Date
    Oct 2009
    Location
    Portugal
    Posts
    25
    and also do i not remember,

    but you can make a small program
    showing the value of keystrokes
    and ctrl -c

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 11-20-2003, 01:27 AM