Combining a mousedown event with a keydown event

Posted by gotguts on Stack Overflow See other posts from Stack Overflow or by gotguts
Published on 2013-07-03T03:42:36Z Indexed on 2013/07/03 5:05 UTC
Read the original article Hit count: 227

Filed under:

I am trying to combine a keydown event with a mousedown event. Basically, I have a chat dialog, and if the user writes in one of 2 divs (keydown event) or makes a selection from either (or both) of 2 dropdowns (mousedown), I need these to have the same exact function. Thanks in advance.

Code (to be combined):

$('#usermsg').add('#otherComments').keydown(function() { // When key pressed

and

$('#strategies').add('#whySwitch').mousedown(function() { // When mouse is clicked
  //function body
});

© Stack Overflow or respective owner

Related posts about jQuery