/    Sign up×
Community /Pin to ProfileBookmark

wanna disable arrow keys as wel as alt key

hi every one,
I want to disable the arrow keys as well as the alt key.
as to fulfill requirement of my project if anyone have some help
regarding this issue please help.

thanks in advanse.

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@WebnerdOct 01.2007 — First, you need to know the key codes for the arrow keys.

Then, you need to attach "onkeydown" events to an element or your body.

Then, you need to use the event cancelling to stop the key event if the user pressed an arrow key.

Open this script in a browser and push keyboard keys. It will show you the key codes to check for.

<i>
</i>
window.onkeydown=function(e){

var k=e ? e.which : window.event.keyCode;

alert(k);


}
Copy linkTweet thisAlerts:
@baranwalravi123authorOct 01.2007 — thankyou very much

i am greatful to you

hi its not working what i do my code is as

<html>

<head>

<script language="javascript">

window.onkeydown=function(e)

{

var k=e ? e.which : window.event.keyCode;

alert(k);

}

</script>

</head>

<body>

<h1> hi this is check</h1>

</body>

</html>
Copy linkTweet thisAlerts:
@Tweak4Oct 01.2007 — Of course, disabling keys is generally considered a horrible idea, and a sure-fire way to piss off your users... Just something to keep in mind...
Copy linkTweet thisAlerts:
@WebnerdOct 01.2007 — 
and a sure-fire way to piss off your users
[/quote]

Maybe the goal of the project is precisely to do that :-)
Copy linkTweet thisAlerts:
@baranwalravi123authorOct 01.2007 — hi all

actually i have written code for disabling the F5 key as

document.onkeydown = function(){

if(window.event && window.event.keyCode == 116)

{ // Capture and remap F5

window.event.keyCode = 505;

}

if(window.event && window.event.keyCode == 505)

{ // New action for F5

return false;

// Must return false or the browser will refresh anyway

}

but not getting proper idea abt Alt,up,down,left,right key

if any one give some help then it will be great

thanks
Copy linkTweet thisAlerts:
@Declan1991Oct 01.2007 — Do the same thing as you have done for F5, except change the codes to the correct keys.

Disabling the arrow keys and the alt key will mean that many users who rely on those keys for navigation won't be happy.
×

Success!

Help @baranwalravi123 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,
)...