Question: I am trying to bind a blur and keyup event handler to a textbox; I only want the logic to execute on all blur events and in the event of the keyup, only upon the user hitting Enter/ return (code 13). This should be simple if I can tell which of the events were captured, but I can't seem to find something that describes what I need to look for. Quick few points for a simple answer.

Answer: 
You can use the jQuery [event object](http://api.jquery.com/category/events/event-object/) to get info about the event. [`event.type`](http://api.jquery.com/event.type/) will tell you which event was triggered.

```
$('#textBox').bind('blur keyup', function(e){
   if( e.type === 'blur' || (e.type === 'keyup' && e.which === 13) ){
     // Code...
   }
});

```

You can also just check [`event.which`](http://api.jquery.com/event.which/) which will be `undefined` when it's a `blur` event.

```
$('#textBox').bind('blur keyup', function(e){
   if( typeof e.which === 'undefined' || e.which === 13 ){
     // Code...
   }
});

```
Use `event.type`:

```
$('input:text').bind('keyup blur',
                     function(e){
                         alert(e.type);
                     });

```

[JS Fiddle](http://jsfiddle.net/davidThomas/mRVq7/).

```
$('input:text').bind('keyup blur',
                     function(e){
                         var t = e.type;
                         if (t == 'blur'){
                             $(this).css('background-color','red');
                         }
                         else if (t== 'keyup') {
                             $(this).css('background-color','green');
                         }
                     });

```

[JS Fiddle demo](http://jsfiddle.net/davidThomas/mRVq7/1/).

Reference:

* [`event.type`](http://api.jquery.com/event.type/).