0

For eg..onmousedown is the attribute name for the script to be run when mouse button is pressed inside TextArea. Similarly, I want to know the attribute name in Text Area for clicking on TextArea's up and down arrow buttons

I want to write a js function when the arrow(up or down buttons) is clicked. So i need attribute name. Thanks.

I meant to (Text Area's Up and Down Arrows) and not key board up and down arrows. Thanks

For eg. We are typing comment here(TextArea) in StackOverflow. Here we able to see the up and down buttons. When we click this, some action to be performed. Text Area here is similar to I am having.Thanks

Is there any specific function for scrolling up and scrolling down. "onscroll" triggers when scrolling up/down happens. Thanks

  • Are you talking about scrolling? – Burhan Khalid Aug 20 '12 at 05:47
  • Not scrolling. Just clicking on up/down arrows in textarea's right side.Even you can see when you add comment here.Thanks. –  Aug 20 '12 at 06:14
  • Can you post a screenshot? I don't see any up and down arrows anywhere in the comment box. – Burhan Khalid Aug 20 '12 at 06:15
  • Just you click "Add Comment" button here. You can see the text area with up and down arrows. It is similar to what I am having. Thanks –  Aug 20 '12 at 06:16
  • John, I think you have some custom browser control thing going on. What browser are you using? There are no up or down arrows in Chrome. See [this screenshot](https://www.dropbox.com/s/t3cimyzblr1ff42/add-comment.jpg) – Burhan Khalid Aug 20 '12 at 06:20
  • @John As they're part of the browser's chrome rather than DOM elements, you cannot add a `click` listener to them. You'll have to listen for the [scrolling](https://developer.mozilla.org/en-US/docs/DOM/element.onscroll) they cause on the ` – Jonathan Lonowski Aug 20 '12 at 06:22
  • I am using IE 9. It is showing the up and down arrows. –  Aug 20 '12 at 06:22
  • @Jonathan Lonowski, Yes.onscroll is working fine as I expected.Thanks. –  Aug 20 '12 at 06:28
  • @Burhan Khalid, Yes. As you said first, what I meant is comes under scrolling. Thanks. –  Aug 20 '12 at 06:29
  • Is there any specific function for scrolling up and scrolling down. "onscroll" triggers when scrolling up/down happens. Thanks. –  Aug 20 '12 at 06:42
  • @John Checkout http://stackoverflow.com/questions/4326845/how-can-i-determine-the-direction-of-a-jquery-scroll-event for that. – Jonathan Lonowski Aug 20 '12 at 07:38

2 Answers2

0
$(document).keydown(function(e){
    if (e.keyCode == CharCodeOfWantedKey){
//do stuff;
}
}); 

Char code of up arrow is 38, for down arrow 40.

loler
  • 2,594
  • 1
  • 20
  • 30
  • I meant to (Text Area's Up and Down Arrows) and not key board up and down arrows. Thanks –  Aug 20 '12 at 05:52
  • Here are a lot of questions about it see these ones: http://stackoverflow.com/questions/1222915/can-one-use-window-onscroll-method-to-include-detection-of-scroll-direction & http://stackoverflow.com/questions/7154967/jquery-detect-scrolldown – loler Aug 20 '12 at 05:55
  • The links above provided is for scrolling. But I need, when clicking on up and down arrows in text area. For eg. We are typing comment here(TextArea) in StackOverflow. Here we able to see the up and down buttons. When we click this, some action to be performed. Text Area here is similar to I am having.Thanks –  Aug 20 '12 at 06:01
  • I think, then you need some hacks `z-index`ed div on top or something painful like that :D – loler Aug 20 '12 at 06:09
0
$('#TextAreaElement').bind('keyup', function(e) { if (e.keyCode == CharCodeOfWantedKey){
//do stuff;
} } );
Vikas
  • 24,082
  • 37
  • 117
  • 159
  • I meant to (Text Area's Up and Down Arrows) and not key board up and down arrows. Thanks –  Aug 20 '12 at 05:53