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...
   }
});

```
```
$('input').keyup(function(e){

    var code = (e.keyCode ? e.keyCode : e.which);

    if(code == 13) /* enter was pressed */
        your_function();

});

```