Skip to content

Commit

Permalink
Fix issue when release Alt key before H key
Browse files Browse the repository at this point in the history
  • Loading branch information
j3soon committed Feb 19, 2022
1 parent 45e1cc4 commit 2aa14db
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions speech-to-windows-input/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ private static bool kbdHook_KeyDownEvent(llc.KeyboardHook sender, uint vkCode, b
{
if (vkCode == (uint)Keys.H && !keyHDown)
{
keyHDown = true;
if (llc.Keyboard.IsKeyDown((int)Keys.Menu))
{
keyHDown = true;
ToggleSTT();
return true;
}
Expand All @@ -261,15 +261,15 @@ private static bool kbdHook_KeyDownEvent(llc.KeyboardHook sender, uint vkCode, b
}
else if (vkCode >= (uint)Keys.D0 && vkCode <= (uint)Keys.D9 && !keyConfigDown)
{
keyConfigDown = true;
if (config.UseSwitchConfigKey && llc.Keyboard.IsKeyDown((int)Keys.Menu))
{
keyConfigDown = true;
configId = (vkCode - (uint)Keys.D0);
shouldReloadConfig = true;
return true;
}
}
else if (vkCode == (uint)Keys.Escape)
else if (vkCode == (uint)Keys.Escape && !injected)
{
if (recognizing)
{
Expand All @@ -282,7 +282,11 @@ private static bool kbdHook_KeyDownEvent(llc.KeyboardHook sender, uint vkCode, b
private static bool kbdHook_KeyUpEvent(llc.KeyboardHook sender, uint vkCode, bool injected)
{
if (vkCode == (uint)Keys.H && keyHDown)
{
keyHDown = false;
if (!llc.Keyboard.IsKeyDown((int)Keys.Menu))
llc.Keyboard.SendKey((int)Keys.Escape);
}
else if (vkCode == (uint)Keys.Apps && keyAppsDown)
{
if (config.UseMenuKey)
Expand All @@ -300,7 +304,11 @@ private static bool kbdHook_KeyUpEvent(llc.KeyboardHook sender, uint vkCode, boo
}
}
else if (vkCode >= (uint)Keys.D0 && vkCode <= (uint)Keys.D9 && keyConfigDown)
{
keyConfigDown = false;
if (!llc.Keyboard.IsKeyDown((int)Keys.Menu))
llc.Keyboard.SendKey((int)Keys.Escape);
}
return false;
}
private static String GetCommonPrefix(String s1, String s2)
Expand Down

0 comments on commit 2aa14db

Please sign in to comment.