Thread: Capturing ALT in C

  1. #1
    Registered User johnnyd's Avatar
    Join Date
    Mar 2002

    Unhappy Capturing ALT in C

    Hey all, I have an issue, I would like to be able to detect the trigger of the ALT button when it is merely pressed so that it can be treated like any other button on the keyboard. I know it can be done, I just don't know how.

    I'm using Boreland C++ 5.02 and I'm coding a console app in C.

    I've tried all of the following:
    1) Keyboard Handlers - far too complicated for such a simple task, and further more, I only want to capture the depress of the ALT key, not hijack the keyboard from Windows...

    2) The Double Scan routine using getch() - doesn't work for my purposes. This routine does work, however, the user has to press ALT AND another key. I only want the user to press ALT alone to trigger an action. Y'know like how ALT triggers the activation of the drop down menu in DOS Editor? Yeah, like that.

    If any of you smart guys can show me how it's done, without re-inventing the wheel, please respond. Thanks in advance.
    Excuse me, while I water my money tree.

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    GetAsyncKeyState() from <windows.h>

    check the docs at msdn or in your help files for its use.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :-

  3. #3
    Registered User johnnyd's Avatar
    Join Date
    Mar 2002

    Smile Yeah but how do I use it?

    Hey thanks.

    I see where GetAsyncKeyState will help, the only problem is, the help does NOT show how I can USE this command!

    I'm still a bit lost. Do you know how to use the command?
    Excuse me, while I water my money tree.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Disable ALT key commands
    By Lionmane in forum Windows Programming
    Replies: 9
    Last Post: 09-23-2005, 10:41 AM
  2. how to capture CTRL, SHIFT and ALT ?
    By goldenrock in forum C Programming
    Replies: 3
    Last Post: 11-06-2003, 01:20 AM
  3. Trapping Ctrl Alt Delete
    By emus21 in forum A Brief History of
    Replies: 14
    Last Post: 09-17-2003, 12:10 PM
  4. Capturing key stokes
    By subdene in forum C++ Programming
    Replies: 20
    Last Post: 08-13-2002, 03:51 PM
  5. Thanks Stoned_Coder! ALT key works!!
    By johnnyd in forum C Programming
    Replies: 0
    Last Post: 03-11-2002, 10:39 AM