• Advertisement

Archived

This topic is now archived and is closed to further replies.

How to detect data for a few keys on a USB keyboard

This topic is 5778 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi guys, I am quite new here, but it seems like everybody here is quite helpful. Actually, I am trying to detect these few keys from a USB keyboard. The keys are CUT, PASTE, COPY, HELP, and STOP. I have tried two aproaches in tackling this problem, which is detecting their ASCII code by using the keyboard hook method. The API function that I used including GetKeyboardState(), ToAscii() and GetKeyNameText(). Other normal standard keys are identified except these 5 keys. Then I tried another method by detecting their Virtual Key codes with the API function GetKeyState(). However these five keys still can''t be detected. So I don''t know what to do next. But it seems like there is a table called USB HID Usage Table which shows that the codes for the keys are:- CUT = H7B (Dec: 123) PASTE = H7D (Dec: 125) COPY = H7C (Dec: 124) HELP = H75 (Dec: 117) STOP = H78 (Dec: 120) I am still not sure how to get those data yet. Any ideas? Thx a lot

Share this post


Link to post
Share on other sites
Advertisement
most of the usb keys are translated to actual keyboard shortcut by the OS. so pressing the copy button is the equvilent of pressing ctrl+c.

common keyboard shortcuts (ie the windows standard):
copy: ctrl c
paste: crtl v
cut: crtl x
help: f1

and i have no idea what stop would be. most likly whatever ie uses as a shortcut for that (i dont know, since i tend not need to stop pages from loading).

if this dont work (ie treating them like regualr windows shortcut key combos) you may wish to look up reading extended usb hid information. usb keyboards are ussually treated as ps2 keyboards on a usb port (in fact many keyboards can be used either way). there are ps2 keyboards that have those extra keys as well, and work fine even though they using the ps2 port (i know since i have used them).

Share this post


Link to post
Share on other sites

  • Advertisement