Login | Register | FAQ
Anonymous

trigger button with enter key

+ Post a reply

3 posts Page 1 of 1


trigger button with enter key

by gmath » Mon Aug 20, 2012 4:54 am

How do you code the script to be run when the user presses the enter key on the keyboard?
User avatar

gmath

  • Posts: 3
  • Joined: Sat Aug 18, 2012 11:15 pm

Re: trigger button with enter key

by gmath » Mon Aug 20, 2012 5:30 am

I found this...should've searched better before asking.

I already have JQuery code written to run when the button is pressed using this:


$('#button_id').click(function() {

button code

});



So in the js file I put in the following separately (inside document ready):


$('#button_id').keyup(function(e) {
if(e.keyCode == 13){

button code

}
});
User avatar

gmath

  • Posts: 3
  • Joined: Sat Aug 18, 2012 11:15 pm

Re: trigger button with enter key

by XainPro » Tue Aug 21, 2012 8:12 am

i agree with gmath you should Google before asking its very easy and have billion of tutorials on net how to do this by searching on Google you will fins your solution instantly rather then waiting peoples to answer for your question.
User avatar

XainPro

  • Posts: 3669
  • Joined: Fri Feb 17, 2012 8:10 pm


+ Post a reply

Page 1 of 1