Author: Jonas Bilinkevicius
How to detect whether the default or the keypad Enter key was pressed
Answer:
You could put something like this on an Application.OnMessage event, or trap the
WM_KEYUP message in your component:
1 procedure TForm1.FormCreate(Sender: TObject);
2 begin3 Application.OnMessage := HandleMessage;
4 end;
5 6 procedure TForm1.HandleMessage(var Msg: TMsg; var Handled: Boolean);
7 begin8 Handled := False;
9 if Msg.message = WM_KEYUP then10 begin11 if Msg.wParam = VK_RETURN then12 begin13 if Msg.LParam and (1 shl 24) > 0 then14 ListBox1.Items.Add('Keypad Return pressed')
15 else16 ListBox1.Items.Add('Regular Return pressed')
17 end;
18 end;
19 end;