How would I print out Pressed every time Shift key is pressed?

This is a discussion on How would I print out Pressed every time Shift key is pressed? within the C++ Programming forums, part of the General Programming Boards category; How would I do that? What libraries would I have to use? I want to do this without having a ...

  1. #1
    Emulator
    Join Date
    Feb 2008
    Posts
    43

    Post How would I print out Pressed every time Shift key is pressed?

    How would I do that? What libraries would I have to use? I want to do this without having a global keyboard hook. Maybe see the state for each key every half a second? Can anyone give me an example? Thanks.
    Hand over your source code, and nobody gets hurt.

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,412
    portable libraries like pdcurses or non portable libraries like conio provide keyboard handles. windows.h does too, i think.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    Emulator
    Join Date
    Feb 2008
    Posts
    43
    Can you give me an example? :S
    Hand over your source code, and nobody gets hurt.

  4. #4
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,412
    With ncurses:

    Code:
    int ch;
    ch = getch();
    if (ch == LEFT_SHIFT) printw("Pressed");
    or something like that. Been a while since I last used the pdcurses library. The define should probably be differently named.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Window message loop (Keys)
    By Blackroot in forum Windows Programming
    Replies: 3
    Last Post: 09-12-2006, 05:15 PM
  2. Simulating Shift Key
    By PrimeTime00 in forum Windows Programming
    Replies: 7
    Last Post: 10-15-2004, 05:53 AM
  3. Shift key extended code
    By Unregistered in forum Game Programming
    Replies: 5
    Last Post: 08-23-2002, 12:35 PM
  4. I apologize. Good bye.
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 05-03-2002, 06:51 PM
  5. BST/Red and Black Tree
    By ghettoman in forum C++ Programming
    Replies: 0
    Last Post: 10-24-2001, 10:45 PM

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