Form keydown and keyup messages aren't captured:
public partial class Form1 : Form
{
const int WM_KEYDOWN = 0x100;
const int WM_KEYUP = 0x101;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_KEYDOWN)
{
log("down");
}
if (m.Msg == WM_KEYUP)
{
log("up");
}
base.WndProc(ref m);
}
}
You should override ProcessCmdKey instead
This example is extracted from this article
Probably there is a way to extract the KeyCode from the message passed to the PreFilterMessage as explained in this article