I am working on a project where I can count the keys that are being pressed and to do so I am using the keydown event.
Here is the issue(s)
1. It only captures the keypress if the application is focused. It doesnt have to be inside the textbox, the textbox is only there to show that its working. How do I make it to where I can ahve it minimized and still capture keys?
(In the gif you can see that I am not typing inside the textbox until the end)
- How do I make it capture non capitalized letters? Do I just simply convert it?
Here is a gif showing you how its working http://recordit.co/IKubOT0pin
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace testkeydown
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Window_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.A)
{
textBox.AppendText("A");
}
}
}
}