I want to get the keys pressed on the keyboard either with or without caplock:
private void Window_KeyDown(object sender, System.Windows.Input.KeyEventArgs e
You can check in your KeyDown
event whether CAPS lock
is on or off using Control.IsKeyLocked method. Also, you might need to check if user typed in capital using Shift
key which can be identified using Modifiers
enum like this -
private void Window_KeyDown(object sender, KeyEventArgs e)
{
string key = e.Key.ToString();
bool isCapsLockOn = System.Windows.Forms.Control
.IsKeyLocked(System.Windows.Forms.Keys.CapsLock);
bool isShiftKeyPressed = (Keyboard.Modifiers & ModifierKeys.Shift)
== ModifierKeys.Shift;
if (!isCapsLockOn && !isShiftKeyPressed)
{
key = key.ToLower();
}
}