KeyPreview doesn't work from the Web Browser control. When the WebBrowser has control your FoxPro keystroke events are not getting processed as you are effectively inside of that 'window'. In order to capture events you need to handle the browser's DOM events.
You can call JavaScript functions from FoxPro code and pass in a reference to the FoxPro form, then call that from script code for example.
Here's some basic info on calling JavaScript code in the Web Browser control:
http://www.west-wind.com/weblog/posts/2008/Sep/27/Calling-JavaScript-functions-in-the-Web-Browser-Control+++ Rick ---
>Hi everybody,
>
>I have a form with Web Browser control taking all the form. I set KeyPreview property to .t. and added a code in KeyPress event
>
> if nKeyCode = 27
> thisform.release()
>endif
>
>However, pressing ESC doesn't close the form. Do you know how can I make this form to close on ESC?
>
>Thanks in advance.