OnKeyDown event in Word.

Add-in Express™ Support Service
That's what is more important than anything else

OnKeyDown event in Word.
Trapping the F12 key. 
Dave O'Brien




Posts: 44
Joined: 2019-09-02
I can trap the F12 key in the OnKeyDown event and would like to then remove the key so the standard action doesn't also run.

procedure TIDMWordAddInModule.adxCOMAddInModuleKeyDown(Sender: TObject; var args: TadxKeyDownEventArgs);
begin
   if args.VirtualKey = VK_F12 then
   begin
      args.VirtualKey := 0;
      DoStuff;
   end;
end;


In a standard WinForm OnKeyDown I would set the key to 0 and that is that. Is there any way of removing the key after processing?
Posted 19 Jun, 2023 19:30:38 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hello Dave,

args.Handled := true;

Regards from Poland (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 20 Jun, 2023 02:59:36 Top
Dave O'Brien




Posts: 44
Joined: 2019-09-02
Excellent. Thanks.
Posted 20 Jun, 2023 15:14:02 Top