How to capture key-presses (keyboard-presses)??? 
Author Message
 How to capture key-presses (keyboard-presses)???

I have tried to do a program which would capture all keypresses.

I have WIN95.



Sun, 05 Jan 2003 03:00:00 GMT  
 How to capture key-presses (keyboard-presses)???



Quote:
> I have tried to do a program which would capture all keypresses.

> I have WIN95.

If you do not need to trap ALT-TAB, you can use the WM_KEY and WM_SYSKEY
messages, or DirectInput.

If you need all keys, you will have to use a hook procedure.



Sun, 05 Jan 2003 03:00:00 GMT  
 How to capture key-presses (keyboard-presses)???

Quote:

> I have tried to do a program which would capture all keypresses.

> I have WIN95.

Well, what are you doing? :)

I assume you want an assembly solution (you're here, duh). That being
the case, two solutions present themselves immediately: trapping the
keyboard interrupt (usually int 9 IIRC) or using the int 16h BIOS call.

If you want to trap the keyboard interrupt, you get every key event
as it happens; not just keys being pressed, but keys being released.
To do this, you would write an interrupt handler that reads in the
key event byte from port 60h. Each key on the keyboard is assigned a
special event code. However, some are considered "extended keys" that
first send the value E0h, then sends the key's "extended code" (one
additional byte). The horrible exception to the rule is Pause/Break,
but this is explained in detail elsewhere. Yeah, anyway, basically
you trap int 9 and read in the byte from port 60h. The PCGPE has a
nice article on programming the keyboard this way, including detailed
explanations on handling extended keys (even Print Screen, which sends
SIX bytes) and a complete list of (pre-Windows button keyboard :) key
scan codes.

As for the int 16h interface, perhaps the most useful bit here is
calling int 16h/ah=0 (the Get Keystroke function). This basically
sits in the int 16h function until a key is pressed on the keyboard;
at which point it returns the keyboard scan code in ah and the ASCII
equivalent (if there is one) in al. Also, you can call int 16h/ah=2
to see if any alt or shift buttons are pressed. You can find detailed
information on this in Ralf Brown's Interrupt List. (It's int 16, in
the BIOS section if you have the RBIL Viewer Windows program, which
lets you easily browse by section n_n )

I hope this helps :)
--

                                             -|-E the Icefalcon
(*wuv RBILVIEW.exe*)



Mon, 13 Jan 2003 03:00:00 GMT  
 How to capture key-presses (keyboard-presses)???

Quote:
> I assume you want an assembly solution (you're here, duh). That being
> the case, two solutions present themselves immediately: trapping the
> keyboard interrupt (usually int 9 IIRC) or using the int 16h BIOS call.
> [...]

It looks like he is searching for a windows solution, not a DOS one


Mon, 13 Jan 2003 03:00:00 GMT  
 How to capture key-presses (keyboard-presses)???
where to get RBIL viewer windows programme ?
thank you,
vineet.


Quote:

> > I have tried to do a program which would capture all keypresses.

> > I have WIN95.

> Well, what are you doing? :)

> I assume you want an assembly solution (you're here, duh). That being
> the case, two solutions present themselves immediately: trapping the
> keyboard interrupt (usually int 9 IIRC) or using the int 16h BIOS call.

> If you want to trap the keyboard interrupt, you get every key event
> as it happens; not just keys being pressed, but keys being released.
> To do this, you would write an interrupt handler that reads in the
> key event byte from port 60h. Each key on the keyboard is assigned a
> special event code. However, some are considered "extended keys" that
> first send the value E0h, then sends the key's "extended code" (one
> additional byte). The horrible exception to the rule is Pause/Break,
> but this is explained in detail elsewhere. Yeah, anyway, basically
> you trap int 9 and read in the byte from port 60h. The PCGPE has a
> nice article on programming the keyboard this way, including detailed
> explanations on handling extended keys (even Print Screen, which sends
> SIX bytes) and a complete list of (pre-Windows button keyboard :) key
> scan codes.

> As for the int 16h interface, perhaps the most useful bit here is
> calling int 16h/ah=0 (the Get Keystroke function). This basically
> sits in the int 16h function until a key is pressed on the keyboard;
> at which point it returns the keyboard scan code in ah and the ASCII
> equivalent (if there is one) in al. Also, you can call int 16h/ah=2
> to see if any alt or shift buttons are pressed. You can find detailed
> information on this in Ralf Brown's Interrupt List. (It's int 16, in
> the BIOS section if you have the RBIL Viewer Windows program, which
> lets you easily browse by section n_n )

> I hope this helps :)
> --

>                                              -|-E the Icefalcon
> (*wuv RBILVIEW.exe*)



Tue, 21 Jan 2003 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Capturing key presses...

2. python Newbie Question: key-press capturing.

3. : Intercepting keyboard press/release

4. Keyboard frezes when pressing alt-enter

5. IBM VA close window upon key pressed event

6. Tracking key presses, mouse clicks and mouse movements?

7. many keys pressed at the same time

8. Command-key presses

9. Changing the cursor when control key pressed.

10. Key press events on a window

11. Selecting TAB sheet by pressing TAB key

12. Keycode() - Getting a response to a key press

 

 
Powered by phpBB® Forum Software