Fix Caps lock bug when using some IME on macOS#3728
Conversation
|
@Tyriar Please let me know if you have any comments on this as this bug is really annoying when using VSCode. |
Tyriar
left a comment
There was a problem hiding this comment.
Won't this break non-US keyboard layouts that use characters beyond a-zA-Z?
|
I've tried Taiwan and Japanese layout keyboard and there is no problems. |
|
@Tyriar If there are some other keyboard layouts or something else need me to help to test, just let me know. 😊 This bug has affected me for at least 6 years when I was new to web development with VSCode. |
|
If concern about if (event.key && !event.ctrlKey && !event.altKey && !event.metaKey && event.key.length === 1 && (
(event.keyCode >= 65 && event.keyCode <= 90) ||
(event.keyCode >= 97 && event.keyCode <= 122)
)) {
// Include only keys in A-Z/a-z.
// HACK: Need process these key events in 'onkeypress' to fix a IME bug on macOS Chrome. fix for #2457
- return true;
+ const c = event.key.charCodeAt(0)
+ if ((c >= 65 && c <= 90) || (c >= 97 && c <= 122)) {
+ return true;
+ }
}
If you think this solution is acceptable, I can push a commit with this. |
|
@Tyriar May I know is there feed back? Thank you |
src/browser/Terminal.ts
Outdated
| )) { | ||
| // Include only keys in A-Z/a-z. | ||
| // HACK: Need process these key events in 'onkeypress' to fix a IME bug on macOS Chrome. fix for #2457 | ||
| return true; |
There was a problem hiding this comment.
Related to #3728 (comment), here is the review comment with suggestion change. Welcome to commit suggestion If you think this is a better solution.
| return true; | |
| const c = event.key.charCodeAt(0); | |
| if ((c >= 65 && c <= 90) || (c >= 97 && c <= 122)) { | |
| return true; | |
| } |
|
@Tyriar @meganrogge World you please take a look on this? Hope to give some advice if possible. |
Fixes #2457
Fixes #3155
The reason for this bug is that when Chrome uses some specific input methods and keydown, it will enter a key that is inconsistent with the actual one.
But in
onkeypress, it can return the correctkeyCode. Therefore, the solution to this problem is to only process characters (A-Za-z) duringonkeypress.In addition to the macOS built-in Pinyin input method proposed in the earlier issue, some other macOS third-party input methods such as OpenVanilla will encounter the same problem.
Fixes microsoft/vscode#109565
Fixes microsoft/vscode#69367
Fixes microsoft/vscode#138028