{"action":"created","issue":{"url":"https://api.github.com/repos/glfw/glfw/issues/672","labels_url":"https://api.github.com/repos/glfw/glfw/issues/672/labels{/name}","comments_url":"https://api.github.com/repos/glfw/glfw/issues/672/comments","events_url":"https://api.github.com/repos/glfw/glfw/issues/672/events","html_url":"https://github.com/glfw/glfw/issues/672","id":123897090,"number":672,"title":"Char Mods callback doesn't trigger when CTRL is pressed (Windows)","user":{"login":"ocornut","id":8225057,"avatar_url":"https://avatars.githubusercontent.com/u/8225057?v=3","gravatar_id":"","url":"https://api.github.com/users/ocornut","html_url":"https://github.com/ocornut","followers_url":"https://api.github.com/users/ocornut/followers","following_url":"https://api.github.com/users/ocornut/following{/other_user}","gists_url":"https://api.github.com/users/ocornut/gists{/gist_id}","starred_url":"https://api.github.com/users/ocornut/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ocornut/subscriptions","organizations_url":"https://api.github.com/users/ocornut/orgs","repos_url":"https://api.github.com/users/ocornut/repos","events_url":"https://api.github.com/users/ocornut/events{/privacy}","received_events_url":"https://api.github.com/users/ocornut/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-25T20:38:52Z","updated_at":"2015-12-26T06:42:20Z","closed_at":null,"body":"@dougbinks may be interested\r\n\r\nTested on current master (as of today) with 'events.c' demo on Windows 8.\r\nThe callback set from glfwSetCharModsCallback is called when ALT modifier is modified (as messaged via WM_SYSCHAR) but not when CTRL modified is pressed. Making it hard for an application to process shortcuts (e.g. CTRL+S) while relying on translated characters.\r\n\r\nI have looked into it, surprising enough it appears that it is a bit of a pain to retrieve this information under Windows.\r\n\r\nAdding this at the end of message handler for keys messages appears to fix it, albeit in a rather ugly way:\r\n```\r\n        case WM_KEYDOWN:\r\n        case WM_SYSKEYDOWN:\r\n        case WM_KEYUP:\r\n        case WM_SYSKEYUP:\r\n[...]\r\n            if ((uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN) && (mods & GLFW_MOD_CONTROL))\r\n            {\r\n                static BYTE keys[256] = { 0 };\r\n                WCHAR buf[4];\r\n                int buf_sz;\r\n                int n;\r\n                keys[VK_SHIFT] = (mods & GLFW_MOD_SHIFT) ? 0x80 : 0;\r\n                buf_sz = ToUnicodeEx(wParam, scancode, keys, buf, 4, 0, NULL);\r\n                for (n = 0; n < buf_sz; n++)\r\n                    _glfwInputChar(window, buf[n], getKeyMods(), FALSE);\r\n            }\r\n\r\n            break;\r\n```\r\n\r\nAs I understand it, DefWindowProc generates WM_CHAR / WM_SYSCHAR messages from WM_KEYDOWN / WM_SYSKEYDOWN messages, and code above replicated the effect for me. It looks a little dodgy but I haven't spotted a flaw with it yet. \r\n\r\nIt might fail on certain edge cases (I don't know them) but I am tempted to say that it can't be a regression since currently we get nothing under Windows when CTRL is held. \r\n\r\n(With Microsoft IME active when holding is doesn't popup anyway so I typically get the Latin character in this case, which is desirable)"},"comment":{"url":"https://api.github.com/repos/glfw/glfw/issues/comments/167285050","html_url":"https://github.com/glfw/glfw/issues/672#issuecomment-167285050","issue_url":"https://api.github.com/repos/glfw/glfw/issues/672","id":167285050,"user":{"login":"shurcooL","id":1924134,"avatar_url":"https://avatars.githubusercontent.com/u/1924134?v=3","gravatar_id":"","url":"https://api.github.com/users/shurcooL","html_url":"https://github.com/shurcooL","followers_url":"https://api.github.com/users/shurcooL/followers","following_url":"https://api.github.com/users/shurcooL/following{/other_user}","gists_url":"https://api.github.com/users/shurcooL/gists{/gist_id}","starred_url":"https://api.github.com/users/shurcooL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shurcooL/subscriptions","organizations_url":"https://api.github.com/users/shurcooL/orgs","repos_url":"https://api.github.com/users/shurcooL/repos","events_url":"https://api.github.com/users/shurcooL/events{/privacy}","received_events_url":"https://api.github.com/users/shurcooL/received_events","type":"User","site_admin":false},"created_at":"2015-12-26T06:42:20Z","updated_at":"2015-12-26T06:42:20Z","body":"I don't think you can use characters for determining shortcut presses like Ctrl+S or Alt+S. The modifier keys Ctrl or Alt may modify how characters get processed. For example, on some keyboard layouts, pressing Alt+S generates a 'ß' character."}}