/    Sign up×
Community /Pin to ProfileBookmark

Keydown Left and Right arrow for next page Problem

I’m using this code for the left arrow (and a similiar code for right arrow), to go to the next page when pressed. The code works fine, without problems. Except I have a comment section which uses a text area. When typing in the textarea I’d like to turn this javascript off so the user can navigate left and right through the text area. Is their anyway to do this? I was thinking if focus on textarea make the key event do nothing. Would anything like that be possible?

[CODE]<script type=”text/javascript”>
$(document).keydown(function(e){
if (e.keyCode == 39) {
//alert( “left pressed” );
window.location.assign(“http://marveldcforum.com/newx.php?x=2”);
return false;
}
});
</script>[/CODE]

Thanks in advance

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@PadonakOct 24.2013 — <i>
</i>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset="utf-8" /&gt;
&lt;title&gt;123&lt;/title&gt;
&lt;script src="http://code.jquery.com/jquery-latest.min.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;center&gt;
&lt;textarea id="comments" rows="5" cols="30"&gt;&lt;/textarea&gt;
&lt;/center&gt;
&lt;script type="text/javascript"&gt;
var busy=false;
$('#comments').focus(function(){busy=true;});
$('#comments').blur(function(){busy=false;});
$(document).keydown(function(e){
if(!busy){
if(e.keyCode==39){
alert("right pressed");
return false;
}
}
});
&lt;/script&gt;
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
×

Success!

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