I was having a problem with keyboard combinations in VSCode etc. Specifically, I started to see that my ctrl + alt combinations stopped working.
I wrote a c# app to debug the problem and when I press left ctrl + left alt (in that order) I only get left ctrl. When I press left alt + left ctrl (in that order) I get alt + System. What does "system" mean? If it's some application grabbing that key combo, any thoughts on how can I tell whick one?
using System;
using System.Windows;
using System.Windows.Input;
namespace KeyCaptureWPF
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
KeyDown += MainWindow_KeyDown;
}
private void MainWindow_KeyDown(object sender, KeyEventArgs e)
{
// Check if the ESC key is pressed
if (e.Key == Key.Escape)
Close();
// Output the pressed key(s)
string keyCombination = GetKeyCombination(e);
OutputTextBlock.Text = $"Key(s) Pressed: {keyCombination}";
}
private string GetKeyCombination(KeyEventArgs e)
{
string combination = string.Empty;
// Check if the key combination includes any modifier keys
if (Keyboard.Modifiers != ModifierKeys.None)
{
if (Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt))
combination += "Alt + ";
if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
combination += "Ctrl + ";
if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
combination += "Shift + ";
}
// Append the pressed key
combination += e.Key.ToString();
return combination;
}
}
}