Here's what I want to do:
I have a hash table which contains data associated to different keys.
The Hash keys are represented by a single character from the keyboard:
0-9, a-z, A-Z, and the other special characters.
I want my program to detect what key the user pressed from the keyboard
and get the associated data from the hash table (associated with the
key he pressed which is the same as the hash key). The user can also
decide to have capital letters (using shift or caps lock).
Here's what I have so far, but it doesn't work:
protected override void OnKeyDown(KeyEventArgs e)
{
if(e.Modifiers == Keys.Shift)
{
if(myHashTable.ContainsKey(e.KeyData.ToString().To Upper()))
foobar(myHash[e.KeyData.ToString().ToUpper()]);
}
else
{
if(myHash.ContainsKey(e.KeyData.ToString().ToLower ()))
foobar(myHash[e.KeyData.ToString().ToLower()]);
}
}
What this code does is that whenever the user presses on Shift, all
other keys are ignored until the function foobar is completely
executed.
Can anyone help me with this? I want to detect if a upper/lower case
letter was pressed and its value.
Thanks.