File tree 1 file changed +18
-2
lines changed
SoundSwitch/Framework/WinApi/Keyboard
1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,22 @@ namespace SoundSwitch.Framework.WinApi.Keyboard
22
22
{
23
23
public static class KeyboardWindowsAPI
24
24
{
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
+ }
25
41
private static byte Code ( Keys key )
26
42
{
27
43
return ( byte ) ( ( int ) key & 0xFF ) ;
@@ -50,7 +66,7 @@ public static IEnumerable<Keys> GetPressedKeys()
50
66
var keyboardState = new byte [ 256 ] ;
51
67
NativeMethods . GetKeyboardState ( keyboardState ) ;
52
68
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 ( ) ;
54
70
}
55
71
56
72
/// <summary>
@@ -131,7 +147,7 @@ private static bool IsModifier(Keys key)
131
147
/// <returns></returns>
132
148
public static IEnumerable < Keys > GetNormalPressedKeys ( )
133
149
{
134
- return GetPressedKeys ( ) . Where ( key => ! IsModifier ( key ) ) . ToList ( ) ;
150
+ return GetPressedKeys ( ) . Where ( key => ! IsModifier ( key ) ) . Except ( Blacklist ) . ToArray ( ) ;
135
151
}
136
152
137
153
#region WindowsNativeMethods
You can’t perform that action at this time.
0 commit comments