VkKeyScan returning same code without modifiers for accented and unaccented letter

◇◆丶佛笑我妖孽 提交于 2019-12-08 19:39:28

It looks like theory 1 - that I wasn't extracting the modifier bits correctly. This code works:

var vkKeyScan = PInvoke.VkKeyScan(character);
var vkCode = vkKeyScan & 0xff;
var shift = (vkKeyScan & 0x100) > 0;
var ctrl = (vkKeyScan & 0x200) > 0;
var alt = (vkKeyScan & 0x400) > 0;

So the problem was either something to do with the operator ordering (i.e. the & may have been taking priority over the >> (bit shift)), although I don't think so as I did try with brackets around the bit shift, OR the shift itself wasn't working as expected.

Here is the commit with working code if you're interested: https://github.com/JuliusSweetland/OptiKey/commit/0e61c52371638c61e0ef05834cd31a363181ea0d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!