Jump to content
Larry Ullman's Book Forums

Recommended Posts

This chapter discusses a topic on keyboard events. I have provided links to my dev website.

 

On page 284, the "change" event is added to the U.addEvent method.

 

 


U.addEvent(U.$('comments'), 'change', limitText);

 

 

http://www.sandiegowebcreative.com/text.html

 

 

On page 284, the "keyup" event is added to the U.addEvent method.

 


U.addEvent(U.$('comments'), 'keyup', limitText);


 

http://www.sandiegowebcreative.com/text2.html

 

 

I don't notice the difference between the two. I receive the same results from my browser, or I may not be noticing that which is obvious (or not as obvious?)

 

Anyone come across this?

Link to post
Share on other sites

Good question. In this case, I have a feeling that there is no noticeable difference between the two (but I could be wrong).

I noticed that the behavior is the same even when you hold a key down.

 

I suppose, in general, I would stick with the keyboard event handlers for pressing keys and use the change event handler for things like selecting items in a select element, etc.

Link to post
Share on other sites

Thanks Hartley, could very well be the reason why on page 287, both events are passed to the function.

 

 


 
U.addEvent(U.$('comments'), 'keyup', limitText);
U.addEvent(U.$('comments'), 'change', limitText);

 

Page 288 goes into detail about accessibility with introducing a concept known as "pairing events". I guess the above is similar to the concept. 

 

 

 
<a href="somepage.html" id="link">Some Text</a>
 
// javascript:
 
addEvent(document.getElementById('link'), 'mouseover', doSomething);
addEvent(document.getElementById('link'), 'focus', doSomething);
 

 

I guess this makes some sense now. 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...