jQuery - Delete a list item with a backspace keypress event?
<p>I would like to be able to click on a list item and then hit the backspace key to delete it. How would I do this with jQuery?</p>

<pre><code>$('&lt;li&gt;Click Me&lt;/li&gt;')
.appendTo('#list')
.click(function(){
   $(this).addClass('delete');
   $(this).focus(); // doesn't seem to do anything maybe??
})
.keypress(function(e){
    // this event handler doesn't fire
    var key = (e.keyCode ? e.keyCode : e.which);
    if (key === 8) {
        if ($(this).hasClass('delete'))
            $(this).remove();
    }
});
</code></pre>

<p>Here's my jsfiddle:</p>

<p><a href="http://jsfiddle.net/prRVc/" rel="nofollow">http://jsfiddle.net/prRVc/</a></p>

<p>Looks like I can't attach a keypress event to a list item.</p>
