WebKit would like to implement this in the (very) near future. Before proceeding, we'd like to hear from other browser vendors that you're <span style="font-family:arial, sans-serif;font-size:13px;border-collapse:collapse">roughly on board with this direction of adding beforeinput and input events.</span><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">Here are the changes I can think of that would result from this:</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="font-size:13px"><div>1) Fire "input" event for contentEditable areas as well as for text-entry form controls.</div>
<div>2) For every case where we'd fire "input", add a ne<span style="border-collapse:separate;font-size:small">w "beforeinput" event that fires before the DOM has been modified.<br>
3) Add a new InputEvent interface with an "action" attribute to use for "input" and "beforeinput" events.</span></div><div><span style="border-collapse:separate;font-size:small">4) For events with an "inserttext" action attribute, also provide a "data" attribute that specifies the text being inserted. For other actions, "data" is the empty string.</span></div>
<div><span style="border-collapse:separate;font-size:small">5) "input" events may be batched as long as they have the same action. In the case of "inserttext" actions, the data attribute is the accumulation of text being inserted. One strange side effect here is that there may be multiple "beforeinput" events per "input" event fire, although it's not unlike having multiple keydown events before a single keyup.</span></div>
<div><span style="border-collapse:separate;font-size:small"><br></span></div><div><span style="border-collapse:separate;font-size:small">The list of actions still needs to be enumerated, but some obvious ones are inserttext, undo, redo, copy, paste, cut and drop. </span></div>
<div><span style="border-collapse:separate;font-size:small"><br></span></div></span></span></font><div>I also think we should get rid of the textInput event in deference to this more useful event, but that's a discussion we can have on www-dom once this is resolved. As far as I know, only WebKit currently implements textInput.</div>
<div><br></div><div>Ojan</div><div><br></div><div class="gmail_quote">On Tue, Jul 14, 2009 at 6:02 PM, Ian Hickson <span dir="ltr"><<a href="mailto:ian@hixie.ch" target="_blank">ian@hixie.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>On Tue, 23 Jun 2009, Ojan Vafai wrote:<br>
><br>
> Currently, textareas and text inputs support the "oninput" event that<br>
> fires on all user-initiated modifications to their content. We should<br>
> add this event to contentEditable elements as well and add an "action"<br>
> property the specifies what action the user took that caused the input<br>
> event.<br>
<br>
</div>I haven't yet added this.<br>
<br>
I think we should probably address the various problems with<br>
contenteditable all at once, to make sure the solution is coherent<br>
overall. I'm watching what happens with the mutation event changes and<br>
tracking proposals for various other changes to contentEditable.<br>
<br>
It may be that we need to defer these changes to after HTML5 reaches last<br>
call, though, and have them in a future version next year some time.<br>
<font color="#888888"><br>
--<br>
Ian Hickson U+1047E )\._.,--....,'``. fL<br>
<a href="http://ln.hixie.ch/" target="_blank">http://ln.hixie.ch/</a> U+263A /, _.. \ _\ ;`._ ,.<br>
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'<br>
</font></blockquote></div><br></div>