I am trying to create an application that changes the value of the button that has been pressed.
Example: If the C button on the keyboard has been pressed then it should output the value of ‘7’. The buttons value should only change for as long as the application is running.
My code so far:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.KeyDown += new KeyEventHandler( Form1_KeyDown );
}
void Form1_KeyDown( object sender, KeyEventArgs e )
{
if (e.KeyCode == Keys.C)
{
}
}
}
All help would greatly be appreciated.
Thanks
If this is in the scope of your application only, I would continue by making a hash map of keys to their binding. (KeyCode => Your-Binding)
If you want an integer value like in your example, you’ll have a map like: