开发者

Is key 'chord' functionality provided by Win32/.net?

Several MS apps support the concept of chords开发者_如何学运维, like CTRL + X , Y which means "holding down CTRL, press X, then Y".

Is this a bespoke thing they (and other companies) implement, or is it built into any APIs? It would be nice to be able to set up event handlers or accelerators based on chords rather than write code to do it.


'Accelerators' support normal key presses plus any combination of Shift, Ctrl, Alt.

For what you are asking for, I think you would need to process WM_KEYDOWN and WM_KEYUP yourself.


There are several solutions using GetKeyAsyncState from which you can directly derive which keys are currently up and down. Tracking every WM_KEYUP/DOWN is not easy and most naive solutions have issues with multiple apps and multiple threads.

A possible solution would be to detect the 'easy' part of the combination with an accellerator (i.e. the ctrl-Y) and then check whether the other keys (i.e. X) are down in the handler.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜