Skip to content

Commit f501549

Browse files
committed
GlobalKeyboardListener: Send a fake KeyUp event if we detect that a released Ctrl/Alt/Shift/Win has been swallowed
1 parent 6e19bcf commit f501549

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Src/GlobalKeyboardListener.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,29 @@ private void recheckPossibleSwallowedKeysTimer(object sender, EventArgs e)
166166
private void recheckPossibleSwallowedKeys()
167167
{
168168
if (_ctrl && WinAPI.GetKeyState((int) Keys.LControlKey) >= 0 && WinAPI.GetKeyState((int) Keys.RControlKey) >= 0)
169+
{
169170
_ctrl = false;
171+
KeyUp(this, new GlobalKeyEventArgs(Keys.LControlKey, 0, new ModifierKeysState(_ctrl, _alt, _shift, _win)));
172+
KeyUp(this, new GlobalKeyEventArgs(Keys.RControlKey, 0, new ModifierKeysState(_ctrl, _alt, _shift, _win)));
173+
}
170174
if (_alt && WinAPI.GetKeyState((int) Keys.LMenu) >= 0 && WinAPI.GetKeyState((int) Keys.RMenu) >= 0)
175+
{
171176
_alt = false;
177+
KeyUp(this, new GlobalKeyEventArgs(Keys.LMenu, 0, new ModifierKeysState(_ctrl, _alt, _shift, _win)));
178+
KeyUp(this, new GlobalKeyEventArgs(Keys.RMenu, 0, new ModifierKeysState(_ctrl, _alt, _shift, _win)));
179+
}
172180
if (_shift && WinAPI.GetKeyState((int) Keys.LShiftKey) >= 0 && WinAPI.GetKeyState((int) Keys.RShiftKey) >= 0)
181+
{
173182
_shift = false;
183+
KeyUp(this, new GlobalKeyEventArgs(Keys.LShiftKey, 0, new ModifierKeysState(_ctrl, _alt, _shift, _win)));
184+
KeyUp(this, new GlobalKeyEventArgs(Keys.RShiftKey, 0, new ModifierKeysState(_ctrl, _alt, _shift, _win)));
185+
}
174186
if (_win && WinAPI.GetKeyState((int) Keys.LWin) >= 0 && WinAPI.GetKeyState((int) Keys.RWin) >= 0)
187+
{
175188
_win = false;
189+
KeyUp(this, new GlobalKeyEventArgs(Keys.LWin, 0, new ModifierKeysState(_ctrl, _alt, _shift, _win)));
190+
KeyUp(this, new GlobalKeyEventArgs(Keys.RWin, 0, new ModifierKeysState(_ctrl, _alt, _shift, _win)));
191+
}
176192
}
177193
}
178194

0 commit comments

Comments
 (0)