Re: Disabling default behavior of function keys

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Joe Fawcett (joefawcett_at_hotmail.com)
Date: 12/07/04


Date: Tue, 7 Dec 2004 15:43:36 -0000


"Guido Kraus" <guido@somewhere.com> wrote in message
news:BA59B196-2383-46B4-A7E9-8686F3365DE9@microsoft.com...
> Hi,
>
> I have to write a web application that has a similar interface like a
legacy
> app. The legacy app uses function keys (F1-F10) for some operations. I use
an
> onKeyDown event handler to trap these keys but unfortunately I don't know
how
> to disable the default behavior of the function keys. For example, IE6
opens
> help if you press F1, it opens its 'Search' pane if you press F3 and so
on.
>
> Is it possible to cancel the default behavior of the function keys?
>
> I tried the following script:
>
> <script LANGUAGE="javascript">
>
> document.onkeydown = function(){
>
> if(window.event && window.event.keyCode == 112) {
> // Capture F1
> event.KeyCode = 0;
> event.cancelBubble = true;
> event.returnValue = false;
> alert('F1 key was pressed');
> return false;
> }
>
> }
>
> Thanks for any ideas,
> Guido
Wll F1 is easy, override the onhelp event:
<body onhelp="return handleOnHelp();">
function handleOnHelp()
{
  //On help code
  return false;
}

For others although they are trappable they are not cancellable outside of
HTML applications.

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/events/onkeydown.asp

-- 
Joe


Relevant Pages

  • Re: About the TreeView in CF.
    ... Alex Yakhnin, Device Application Developer MVP ... i am developing a app which can operated only by keyboard. ... buttons can be "clicked" by Function keys at anytime. ... the keyPressed event is operated by these ...
    (microsoft.public.dotnet.framework.compactframework)
  • About the TreeView in CF.
    ... i am developing a app which can operated only by keyboard. ... buttons can be "clicked" by Function keys at anytime. ... the keyPressed event is operated by these ... distributes the keyPressed event to the control. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Function Keys in Win2K
    ... in an app by pressing the F3 key, yet on other users' PCs ... there somewhere in Win2K where function keys are custom ...
    (microsoft.public.win2000.general)
  • Re: DOS program on XP Pro
    ... I have to navigate entirely with function keys and up/down keys. ... if you cannot get the app to print by any other method... ... I tried that and got the program to run in a window, but still no luck with copy/paste. ... When I place the cursor in the window, I cannot select any text to copy because the mouse ceases to work in that window. ...
    (microsoft.public.windowsxp.basics)