Why is the Backslash key being reported as OemQuote under WPF?

被刻印的时光 ゝ 提交于 2019-12-08 04:37:27

问题


In our WPF application, we were wondering why our CTRL-Backslash keyboard shortcut wasn't firing. Wrote a quick test app to log what key was being pressed, and in the OnKeyDown override, e.Key was being reported as OemQuote and not OemBackslash as expected.

Worse, on someone else's machine (but also with a US keyboard and the US layout too, but a different manufacturer), they get a different value for e.Key altogether.

Yes, I know that's what 'Oem' stands for, but shouldn't all OEMs know what the heck a backslash is and treat it consistently?!!

IF not, which is the case, how are you supposed to be able to assign Backslash to a keyboard shortcut for different machines??

Now I know the OS know's it's a backslash because on both machines, the correct value is typed into a textbox, so obviously the OS (through the driver I'm assuming) knows what to map it to, but I can't believe that I can't create a shortcut based on the backslash and expect it to work reliably on different machines and configurations.

This is crazy to me! Help!!

来源:https://stackoverflow.com/questions/13054534/why-is-the-backslash-key-being-reported-as-oemquote-under-wpf

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