{"id":93406,"date":"2016-05-04T07:00:00","date_gmt":"2016-05-04T21:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/?p=93406"},"modified":"2019-03-13T11:02:41","modified_gmt":"2019-03-13T18:02:41","slug":"20160504-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20160504-00\/?p=93406","title":{"rendered":"How can I detect whether the user&#8217;s keyboard has a Break key?"},"content":{"rendered":"<p>Some time ago, a customer wanted to know whether there was a way to detect whether or not the user&#8217;s keyboard has a <kbd>Break<\/kbd> key. &#8220;Our program has a hotkey that involves the <kbd>Break<\/kbd> key. Nowadays, the trend in laptop keyboards is to remove the <kbd>Break<\/kbd> key, which leaves users no way to invoke the hotkey. We want to offer an alternate hotkey, but only if the user&#8217;s keyboard doesn&#8217;t have a <kbd>Break<\/kbd> key.&#8221; <\/p>\n<p>The device driver people explained that the driver has no idea what physical keys are present on the keyboard. So there&#8217;s no way to know whether a <kbd>Break<\/kbd> key exists, except by inferring the presence of such a key if you ever see a report that says &#8220;Hey, the user hit the <kbd>Break<\/kbd> key.&#8221; <\/p>\n<p>That answers the technical problem: No, there is no way to know whether the keyboard has a physical <kbd>Break<\/kbd> key, or at least no way at the driver level to know. <\/p>\n<p>But even if it were possible, from a user experience point of view, you don&#8217;t want to change the hotkey based on whether the keyboard has a <kbd>Break<\/kbd> key. For one thing, it forces the user to remember additional state: They have to use one hotkey when at their desktop PC, and another hotkey when using their laptop. <\/p>\n<p>The user may have a Bluetooth keyboard paired to the laptop, even though they are actively using the integrated keyboard. If the Bluetooth keyboard has a <kbd>Break<\/kbd> key, the program would require the user to use the <kbd>Break<\/kbd> hotkey, even though the laptop keyboard doesn&#8217;t have a <kbd>Break<\/kbd> key. <\/p>\n<p>If the user is on the edge of Bluetooth range, that Bluetooth keyboard may come and go randomly, at which point the application hotkey changes randomly. <\/p>\n<p>And changing the hotkey based on the keyboard the user typed on most recently is even more crazy. <\/p>\n<p>The customer accepted our explanation that there is no way at the driver level to detect what types of keys are available on the current keyboard, and that even if you knew, you probably shouldn&#8217;t act on it. Best would be to leave both sets of hotkeys active at all times. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Looking at the problem the wrong way.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-93406","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Looking at the problem the wrong way.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/93406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=93406"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/93406\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=93406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=93406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=93406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}