I think that it is better to handle the KeyPress event, where e.KeyChar will be '<'.
KEYS ENUMERATOR
Giorgio Sfiligoi
391
Reputation points
I have not been able to find the 'lower than' (<) and 'greater than' (>) symbols in the Keys enumerator.
I need to capture keystrokes from the user, such as:
private void listTransactions_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control)
{
int index = -1;
switch (e.KeyCode)
{
...
case Keys.Oemcomma: index = 2; break; // <
case Keys.OemPeriod: index = 3; break; // >
...
}
e.Handled = true;
}
}
In the US keyboard the < > symbols are associated with comma and period, thus I used these codes - taking advantage from the fact that the Control modifier is Shift-insensitive.
However, a different keyboard layout will have the < > symbols on other keys: e.g. the IT layout locates them together in a single key.
So my code will not be able to support different layouts?
I also tried:
switch (e.KeyValue)
{
...
case '<': index = 2; break;
case '>': index = 3; break;
...
}
but it does not work.
Developer technologies | Windows Forms
1,934 questions
Windows development | Windows API - Win32
2,787 questions
Developer technologies | C#
11,578 questions