-
Notifications
You must be signed in to change notification settings - Fork 28.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some keys are not recognized correctly when using a Japanese keyboard #23833
Comments
I'd be willing to work on this, if someone more experienced with the codebase could point me in the right direction. |
Quite a lot have changed in the upcoming 1.11 regarding keyboard layouts and keybinding handling. I would suggest to first try to use the Insiders Build and see how it behaves there. I have written a wiki page documenting how keybindings work in VS Code (1.11 - on the insiders channel) at https://github.com/Microsoft/vscode/wiki/Keybindings Please give that a quick read and try to see if the wiki page provides sufficient information for you to understand what's going on. For Japanese, I believe the issue is in |
You're right. Calling |
So I changed keyboard_mac.mm in TISInputSourceRef source = TISCopyCurrentKeyboardInputSource();
CFDataRef layout_data = static_cast<CFDataRef>((TISGetInputSourceProperty(source, kTISPropertyUnicodeKeyLayoutData)));
if (!layout_data) {
// https://developer.apple.com/library/mac/documentation/TextFonts/Reference/TextInputSourcesReference/#//apple_ref/c/func/TISGetInputSourceProperty
args.GetReturnValue().Set(result);
return;
} to TISInputSourceRef source = TISCopyCurrentKeyboardInputSource();
CFDataRef layout_data = static_cast<CFDataRef>((TISGetInputSourceProperty(source, kTISPropertyUnicodeKeyLayoutData)));
if (!layout_data) {
// TISGetInputSourceProperty returns null with a Japanese keyboard layout.
// Using TISCopyCurrentKeyboardLayoutInputSource as a workaround.
source = TISCopyCurrentKeyboardLayoutInputSource();
layout_data = static_cast<CFDataRef>((TISGetInputSourceProperty(source, kTISPropertyUnicodeKeyLayoutData)));
if (!layout_data) {
// https://developer.apple.com/library/mac/documentation/TextFonts/Reference/TextInputSourcesReference/#//apple_ref/c/func/TISGetInputSourceProperty
args.GetReturnValue().Set(result);
return;
}
} which is apparently a workaround for the NULL return value (see this stackoverflow page). When using the modified |
I created a PR for |
Brilliant! |
This issue isn't quite fixed. I can now use the @ key, but the
in the results from |
@landonepps Thanks again for your work! ❤️
Unfortunately I cannot test them as I only have access to ANSI and ISO keyboards, and not to JIS ones. |
To clarify, if I type |
Let's check you have something similar to the OP:
|
I'm using a JIS keyboard on a Mac Mini, specifically this keyboard. As far as I know it's configured correctly, haven't had any other problems with it until today.
|
Does it work if you use the mac's default kotoeri IME instead of the google one? |
Same result for all input methods (Google Alphanumeric, Google Hiragana, Kotoeri Romaji, Kotoeri Hiragana). |
I also added US in OSX preferences and tried that for good measure, same result of those keys being switched. |
Sorry, didn't attach the file |
My current workaround is doing this:
|
@richardkazuomiller Thank you for getting back to us. I think this might be an issue within our C++ code that reads the keyboard layout from the OSX - https://github.com/Microsoft/node-native-keymap The C++ module works by reading the current keyboard layout, and then proceeds to use OSX APIs to convert all scan code + modifier combinations to produced characters. In this case (by looking at the
Looking at the picture this looks incorrect. It appears you have a scan code that produces
This will output the mappings that we use in VS Code. And perhaps you can spot something fishy in that code or debug and see what's going on. Thank you! |
I haven't had time to look at any C++ code yet, but another weird thing started happening. I have two projects open. In one window, the keyboard shortcuts I made work, the other they get overridden because VSCode started to recognize the keyboard properly. I've attached a screenshot. Why does this happen in some windows and not others and how just make it do one or the other? Strangely, the keymapping for |
So weird ... I closed and reopened the window that was recognizing they keyboard input wrong at the time I first commented on this issue, and it start working. Same keyboard, same process (haven't exited VSCode since I posted this), just different window. If I figure out how to reproduce the issue someday I guess I'll come back then. |
@richardkazuomiller This is most weird. Are you perhaps switching between two different keyboard layouts and between two different physical keyboards? The C++ methods we're using have the ...last... word in them. So that might make a difference, i.e. what was the last physical keyboard that was used before that code executes... I'm sorry I'm not an expert either in the OSX APIs. |
Keybindings for certain keys do not work as intended with a Japanese keyboard on macOS. When defining keybindings, the @ key (right of 'P') and '[' key are both recognized as a [. Shift+@ is recognized as shift+`. The ¥ key is 'unrecognized' and shift+¥ is recognized as shift+.
There may be issues with other keys, too. I noticed this one specifically because there is no ` key on a Japanese keyboard and it's used to open the terminal.
I'm using my MacBook's default keyboard which is Japanese. I also have a bluetooth Apple Japanese keyboard that experiences the same issue.
Steps to Reproduce:
Here's a picture of the keyboard layout for reference:
![mla22j](https://cloud.githubusercontent.com/assets/1572318/24593427/4a7be108-185e-11e7-8c53-b04922b6c234.jpg)
The text was updated successfully, but these errors were encountered: