[comp.os.msdos.programmer] Testing for ALT keypress

melling@cs.psu.edu (Michael D Mellinger) (09/19/90)

I am trying to test when a user presses ALT-h, but am not having much
luck.  I found these two library routines in the Microsoft C 6.0
library reference manual, but they don't seem to do the trick for ALT
key sequences(They work fine for Cntrl and Shift keys, however).  I
was masking ch with 0xff to get the proper ascii character and testing
bit 3 in altpress.  Is there something else that I have to do?

    	ch = _bios_keybrd(_KEYBRD_READ); /* get keypress */
 
	altpress = _bios_keybrd(_KEYBRD_SHIFTSTATUS); /* get modifier */


Also, what is a good C programming book for DOS and the IBM?

A couple of years ago I thought that DOS would die off(OS/2 taking its
place), and that I would never have to go through the drudgery of
learning to program in it.  It seems I was wrong :-(.

-Mike

spolsky-joel@cs.yale.edu (Joel Spolsky) (09/19/90)

In article <Fdatuc52@cs.psu.edu> melling@cs.psu.edu (Michael D Mellinger) writes:
>I am trying to test when a user presses ALT-h, but am not having much
>luck.  I found these two library routines in the Microsoft C 6.0
>library reference manual, but they don't seem to do the trick for ALT
>key sequences(They work fine for Cntrl and Shift keys, however).  I
>was masking ch with 0xff to get the proper ascii character and testing
>bit 3 in altpress.  Is there something else that I have to do?

You're doing it wrong; bioskey returns scancodes for the ALT keys,
not ASCII values. It sets the low byte of the result to 0.
Look at the *high* byte of the result, that reflects the keyboard
scancode of the ALT-key combination pressed.

Joel Spolsky
spolsky@cs.yale.edu                                     Silence = Death