/    Sign up×
Community /Pin to ProfileBookmark

Re: firefox enter key event

Hello everyone,
I am very new to this forum as well as to javascript. I have following code for enter key event on my page. its working in all browsers except firefox. I have searched online a lot but nothing has worked and finally I have thought to get some help from the experts.

<script>
function checkKey()
{
if (window.event.keyCode == 13)
{
loadUrl();
}
return true;
}
</script>

onkeydown=”checkKey();return true;”

any help is much appreciated.

Thank you.

Kind Regards.

to post a comment
HTML

1 Comments(s)

Copy linkTweet thisAlerts:
@LutinFouJun 18.2012 — Hi,

window.event is IE specific. Firefox will use the following syntax evt.keyCode.

You could adapt your code by testingfr this, ie. at the very start of your function write

if(!evt){

var evt=window.event;

}

ie if the browser does not use evt, to use window.event

and then throughout your code use evt.keyCode.

This shoul dmake it IE and non-IE compatible.

best regards

LF
×

Success!

Help @raicha spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...