title: Get key pressed from DOM input event (or equivalent solution)
body: <h1>Background:</h1>
  <p>I am writing a script that does some stuff when a user clears an <code>input type=&quot;search&quot;</code> (essentially the same as type=text) using backspace or delete. I want to address the case where user highlights original text and starts typing new text, and also pasting.</p>
  <p>Because of this I cannot use <code>keydown</code> (fires before input value is changed). Cannot use <code>keypress</code> (need to fire when backspace/delete is pressed, and it fires too early as well). Using <code>keyup</code> is bad because I can't clear when <code>value === 1</code> (might already be several characters in the field). I can build in some slop but then it won't clear right away which looks buggy.</p>
  <h1>Question:</h1>
  <p>So the <a href="https://developer.mozilla.org/en-US/docs/Web/Events/input" rel="nofollow noreferrer">DOM input event</a> fires right when the value is updated, which is exactly what I want (tested using jQuery on 'input'). However, I cannot find the captured key (which I need to differentiate between deleting and entering content). I couldn't find great info on the spec. It seems like this is going to be implemented in the <code>data</code> section of the event, which does not yet have any browser support. <strong>Does that mean it is currently impossible to get the key from the <code>oninput</code> event? If so, how do most developers handle this?</strong> I imagine wanting the key immediately after it is entered is very common, surely there is a decent solution for this?</p>
  <h3>Current implementation for the curious:</h3>
  <p>For the time being I am grabbing the value right after <code>keydown</code> by using a <code>setTimeout</code> of 0. This gets me both the key and the updated value, but feels dirty and requires extra handlers for <code>onpaste</code> and such. While writing this it occurs to me I could probably use <code>oninput</code> by keeping track of the last value and comparing to current to differentiate between entering and deleting, but that doesn't seem all that much better, and would still require a separate paste handler since I want my event to fire every time a user pastes, and it doesn't seem to have any flags that would let me know the event was a paste.</p>