Skip to content

Commit 2ab20ea

Browse files
committed
fix(HotKey): Remove detection of any Hanja/Kanji mode key
1 parent 4a06e61 commit 2ab20ea

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

SoundSwitch/Framework/WinApi/Keyboard/KeyboardWindowsAPI.cs

+18-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,22 @@ namespace SoundSwitch.Framework.WinApi.Keyboard
2222
{
2323
public static class KeyboardWindowsAPI
2424
{
25+
private static readonly IEnumerable<Keys> Blacklist;
26+
27+
static KeyboardWindowsAPI()
28+
{
29+
Blacklist = new[]
30+
{
31+
Keys.FinalMode,
32+
Keys.HanguelMode,
33+
Keys.HangulMode,
34+
Keys.HanjaMode,
35+
Keys.JunjaMode,
36+
Keys.KanaMode,
37+
Keys.KanjiMode,
38+
Keys.IMEModeChange
39+
}.Distinct().ToHashSet();
40+
}
2541
private static byte Code(Keys key)
2642
{
2743
return (byte)((int)key & 0xFF);
@@ -50,7 +66,7 @@ public static IEnumerable<Keys> GetPressedKeys()
5066
var keyboardState = new byte[256];
5167
NativeMethods.GetKeyboardState(keyboardState);
5268

53-
return Enum.GetValues(typeof(Keys)).Cast<Keys>().Where(key =>(keyboardState[Code(key)] & 0x80) != 0).ToList();
69+
return Enum.GetValues(typeof(Keys)).Cast<Keys>().Where(key =>(keyboardState[Code(key)] & 0x80) != 0).ToArray();
5470
}
5571

5672
/// <summary>
@@ -131,7 +147,7 @@ private static bool IsModifier(Keys key)
131147
/// <returns></returns>
132148
public static IEnumerable<Keys> GetNormalPressedKeys()
133149
{
134-
return GetPressedKeys().Where(key => !IsModifier(key)).ToList();
150+
return GetPressedKeys().Where(key => !IsModifier(key)).Except(Blacklist).ToArray();
135151
}
136152

137153
#region WindowsNativeMethods

0 commit comments

Comments
 (0)