Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Keybind issue #68 #79

Merged
merged 9 commits into from
Feb 14, 2023
13 changes: 11 additions & 2 deletions Classes/frmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
using Microsoft.Web.WebView2.Core;
using RePlays.Recorders;
using RePlays.Services;
using Squirrel;
using RePlays.Utils;
using static RePlays.Utils.Functions;
using System.Collections.Generic;
using System.IO;
using System;
using System.Globalization;
using System.Threading.Tasks;

namespace RePlays {
public partial class frmMain : Form {
Expand Down Expand Up @@ -294,15 +294,24 @@ private void button1_KeyDown(object sender, KeyEventArgs e) {
Logger.WriteLine(string.Join(" | ", PressedKeys.ToArray()));
}

bool _hasHotkeyTimeout = false;
private void button1_KeyUp(object sender, KeyEventArgs e) {
if(HotkeyService.EditId != null && SettingsService.Settings.keybindings.ContainsKey(HotkeyService.EditId)) {
if(HotkeyService.EditId != null && SettingsService.Settings.keybindings.ContainsKey(HotkeyService.EditId) && !_hasHotkeyTimeout) {
SettingsService.Settings.keybindings[HotkeyService.EditId] = string.Join(" | ", PressedKeys.ToArray()).Split(" | ");
SettingsService.SaveSettings();
WebMessage.SendMessage(GetUserSettings());
HotkeyService.Start();
var cleanupTask = new Task(() => ClearKeys()); cleanupTask.Start();
}
if (webView2 != null) webView2.Focus();
else pictureBox1.Focus();
_hasHotkeyTimeout = PressedKeys.Count >= 2;
}

public async void ClearKeys()
{
await Task.Delay(1000);
_hasHotkeyTimeout = false;
PressedKeys.Clear();
}

Expand Down