Due to my interest in this question I did a little bit of research using GLFW and C++:
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode)
{
if (action == GLFW_PRESS) {
std::cout << std::hex << scancode << std::endl;
}
}
Using this code I can see the following scancodes:
Left Alt: 0x0038
Right Alt: 0x0138
Left Ctrl: 0x001d
Right Ctrl: 0x011d
As you can see the modifier keys on the right hand side of the keyboard have an extended bit(thanks stuartd) and so using GLFW it is possible to distinguish between both alts and both controls.
However, using the .NET Framework in C# as you are I used the following callback:
private void func(object sender, KeyEventArgs e) {
MessageBox.Show(e.KeyValue.ToString());
MessageBox.Show(e.Alt.ToString());
MessageBox.Show(e.Control.ToString());
MessageBox.Show(e.Modifiers.ToString());
}
I also got the results of:
Left Alt: 18 True False Alt
Right Alt: 17 False True Control
Left Ctrl: 17 False True Control
Right Ctrl: 17 False True Control
Because of this I would be inclined to say that this is a limitation of the .NET Framework, at least in the version that I'm using(4.5.2) and that the answer to your question in this case is, no you cannot distinguish between Left Ctrl + Right Alt
and Right Alt
. I suggest you look at this answer and use the Win32 API instead.
Note also that Right Alt
is Alt Gr
.