<input type=”text” />

 

The above returns “g” when “g” is pressed and “G” when “G” is pressed.

 

WHILE…

 

<input type=”text” id=”tb” />

 

someClass = Class.create();

someClass.prototype =

{

            initialize: function()

            {

                        Event.observe($(“tb”), “keypress”, this.showkeyPressed.bindAsEventListener(this) );

            },

 

            showKeyPressed: function(evt)

            {

                        alert(String.fromCharCode(evt.keyCode));

            }

};

 

…returns “G” all the time when the g key I pressed, no matter what. (Simplified example of course)

 

For some weird reason, the event object from proto’s bindAsEventListener method is always returning the capitalized keyCode of the key that was pressed.

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Gregory Hill
Sent: Friday, March 03, 2006 3:07 PM
To: rails-spinoffs@lists.rubyonrails.org
Subject: RE: [Rails-spinoffs] event.keyCode broken in prototype?

 

Code?  Can’t help much without seeing what you’re doing.

 

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Ryan Gahl
Sent: Friday, March 03, 2006 1:48 PM
To: rails-spinoffs@lists.rubyonrails.org
Subject: [Rails-spinoffs] event.keyCode broken in prototype?

 

I ran 2 tests. One using proto’s Event.observe, and another using an in-line handler of the “keydown” event in a textbox.

 

Using .bindAsEventListener, the event.keyCode is always returning a capital letter, no matter what. The in-line event handler returns lowercase vs. uppercase correctly… What’s going on?

 

I guess I find it hard to believe no one has tried capturing keyboard events before, so I’m hoping I’m just royally screwing something up. Can anyone help me on this?

The information transmitted in this electronic mail is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material.  Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers.

_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to