React when Browser Text Input Changed through Mouse Action
<p>I have a text input field and a checkbox.  The checkbox must be disabled if and only if there is input in the text field.  I have a solution that works great for most scenarios:</p>

<p>HTML:</p>

<pre><code>&lt;input type="text" id="search" /&gt;
&lt;input type="checkbox" id="cb" /&gt;
&lt;label for="cb"&gt;Enabled only if no search term&lt;/label&gt;
</code></pre>

<p>jQuery:</p>

<pre><code>$('#search').keyup(function (e) {
    var enable = $(this).val() == 0;
    if (enable) {
        $('#cb').removeAttr('disabled');
    } else {
        $('#cb').attr('disabled', 'disabled');
    }
});
</code></pre>

<p>See it <a href="http://jsfiddle.net/ericjohannsen/WDMCX/" rel="nofollow">live on jsFiddle</a>.</p>

<p>This works when text is typed or removed using the keyboard, and when text is pasted using the keyboard.</p>

<p>It fails if the user pastes text using the right-click context menu, or if the user presses the little "X" that IE adds to the input field to allow the input field to be cleared.</p>

<p><strong>Question</strong></p>

<p>How can I improve the code so that it also works in those scenarios?  Waiting for the textbox to lose focus would provide an inferior user experience.</p>
