center-for-threat-informed-defense / attack-flow

Attack Flow helps executives, SOC managers, and defenders easily understand how attackers compose ATT&CK techniques into attacks by developing a representation of attack flows, modeling attack flows for a small corpus of incidents, and creating visualization tools to display attack flows.
https://ctid.io/attack-flow
Apache License 2.0
522 stars 83 forks source link

AF-155: Improved Hotkeys #106

Closed mikecarenzo closed 10 months ago

mikecarenzo commented 10 months ago

Overview

Improves hotkey stability and separates settings for Windows/Linux and MacOS.

Improved Hotkey Stability

This PR introduces a set of stability enhancements to the HotkeyObserver. Originally, the HotkeyObserver tracked the current state of the keyboard by monitoring keydown and keyup events. In effect:

Unfortunately, there are cases where a keydown event DOES NOT trigger an associated keyup event. For instance:

As a result, the HotkeyObserver is occasionally led to believe that certain keys are still being held down even when the user's hands are off the keyboard. What's worse, if the user tries another hotkey combination, the pressed keys will be added to an already incorrect key state, the corrupted key state will fail to match any registered hotkeys, and nothing happens.

The initial implementation of HotkeyObserver attempted to account for this keyup quirk. However, the list of reasons keyup doesn't fire has grown to a point where it no longer makes sense to rely on it.

Now, the keyboard state is assessed using everything that can be gleaned from a single KeyboardEvent (raised by keydown). This includes the currently pressed key and any associated modifier keys (Control, Alt, Shift, and Meta). While this limits possible hotkey sequences, it does remove the need to track the current key state across keydown and keyup events.

Separate Hotkey Settings for Windows/Linux and MacOS

This PR replaces settings.json with settings_win.json and settings_macos.json. Both .json enumerate the same list of settings (with different values) and allow the application to be configured dynamically depending on the device's current operating system. This new feature has been used to add support for MacOS style hotkeys.

mehaase commented 10 months ago

@mikecarenzo As you merge the hotkeys from the search branch, I wanted to highlight this comment from PR #99:

I ended up going with F3 for "Find Next" and Shift+F3 for "Find Previous" to match how notepad.exe works. (On MacOS it would usually be Cmd+G and Cmd+Shift+G, I think, but that might conflict with the "Grid" hotkey.)

Screenshot 2023-08-28 at 3 30 59 PM
sonarcloud[bot] commented 10 months ago

SonarCloud Quality Gate failed.    Quality Gate failed

Bug B 1 Bug
Vulnerability A 0 Vulnerabilities
Security Hotspot E 1 Security Hotspot
Code Smell A 4 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

mikecarenzo commented 10 months ago

@mehaase I'd like to stick to the Operating System's conventions as closely as possible. On MacOS I changed the "Grid" shortcut to Option+G. I also tweaked the way shortcut text appears so that it aligns with OS conventions.

shortcut_conventions
mehaase commented 10 months ago

The MacOS shortcuts look great! Thanks for picking up on that detail.