# AJAX Event Handlers, like shift key pressing

**URL:** <https://www.ruby-forum.com/t/ajax-event-handlers-like-shift-key-pressing/102474>\
**Category:** Rails\
**Created:** [February 8, 2006, 8:06pm UTC](https://www.ruby-forum.com/t/ajax-event-handlers-like-shift-key-pressing/102474 "2006-02-08T20:06:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joshua\_Gitlin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ac91a4/32.png) [@Joshua\_Gitlin](https://www.ruby-forum.com/u/Joshua_Gitlin)\
**Post date:** [February 8, 2006, 8:06pm UTC](https://www.ruby-forum.com/t/ajax-event-handlers-like-shift-key-pressing/102474/1 "2006-02-08T20:06:35Z")

</div>

Hey everyone,

I thought I’d seen a demo of an AJAX app that responded to control  
key presses, like performing a different action when the shift key is  
pressed. What I’d really like to do is have a div change when the  
shift key is pressed (to change the text of the link inside it to  
indicate what new action will occur when that link is clicked with  
shift held down). Is there a rails way of doing this?

-Josh

---

<div class="post-metadata">

**Author:** ![Joshua\_Gitlin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ac91a4/32.png) [@Joshua\_Gitlin](https://www.ruby-forum.com/u/Joshua_Gitlin)\
**Post date:** [February 8, 2006, 10:38pm UTC](https://www.ruby-forum.com/t/ajax-event-handlers-like-shift-key-pressing/102474/2 "2006-02-08T22:38:30Z")

</div>

On 08 Feb 2006, at 20:06, Joshua Gitlin wrote:

> Hey everyone,
> 
> I thought I’d seen a demo of an AJAX app that responded to control  
> key presses, like performing a different action when the shift key  
> is pressed. What I’d really like to do is have a div change when  
> the shift key is pressed (to change the text of the link inside it  
> to indicate what new action will occur when that link is clicked  
> with shift held down). Is there a rails way of doing this?

I don’t believe you can detect a modifier being pressed using  
JavaScript (as this is a client-side detection), unless combined with  
a conventional keydown.

Check [Detecting The Shift/Ctrl/Alt Keys](http://www.cross-browser.com/x/examples/shift_mode.php) for an  
example.

Best regards

Peter De Berdt
