Capturing keystrokes

Chris wendlec at tcd.ie
Fri Feb 7 05:52:13 PST 2014


On Friday, 7 February 2014 at 12:32:25 UTC, Paul Freund wrote:
> On Friday, 7 February 2014 at 12:17:42 UTC, Chris wrote:
>> Just out of interest, is there a way of capturing keystrokes 
>> in D? E.g. if you have a CLI application that wants to capture 
>> Ctrl+... and the like, and possibly control the cursor.
>
> You can achieve this by interfacing operating system functions. 
> If your target is windows you can take a look at my 
> ScrollLocker project 
> (https://github.com/PaulFreund/ScrollLocker). It is written in 
> D and uses SetWindowsHookEx and WH_KEYBOARD_LL (low level 
> keyboard hook) to capture key strokes (see helper/hooks.d). 
> There should be similiar facilitys in other OS as well.
>
> It should also be possible to get certain combinations in the 
> cmd/shell but I don't know how.

Thanks for the link. It's a good starting point. I'm on Linux, so 
I'll have a look at the corresponding functions.


More information about the Digitalmars-d mailing list