Question
“How do I prevent my computer from beeping when I press the ESC button in the preview?”
Solution
Create a preview plugin that overrides the KeyDown event. Inside this event, check for the escape key press and change it preventing the default beep.
Download: NoBeepOnESC.zip
Sample Delphi code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
TMyPreviewPlugin = class(TppPreview) private protected procedure KeyPressEvent(Sender: TObject; var Key: Char); override; public constructor Create(aOwner: TComponent); override; end; implementation procedure TMyPreviewPlugin.KeyPressEvent(Sender: TObject; var Key: Char); begin inherited; if (Key = #27) then //If the key pressed is ESC, change it. Key := #0; end; initialization TppPreviewPlugIn.Register(TMyPreviewPlugin); finalization TppPreviewPlugIn.UnRegister(TMyPreviewPlugin); end. |