anchor.diff:      });
       _element.onKeyDown.listen((Event e) {
         Logger.root.info("overwrite got key down which: ${e.which}");
  -      Logger.root.info("_length: $_length, new length: ${_element.value.length}");
  +      Logger.root.info("_length: ${_element.maxLength}, new length: ${_element.value.length}");
         if(_element.selectionStart == _element.selectionEnd) { 
           if(e.which == 8) {
             // don't do anything if cursor is at the end
  
positive.code: class Overwrite {
    // the element to implement overwrite mode in
    TextAreaElement _element;
    // the length of the text in the element
    int _length;
    
    /// Create an overwrite object that implements overwrite mode on the input element 
    Overwrite(TextAreaElement this._element) {
      _length = _element.value.length;
      _element.onPaste.listen((Event e) {
        // save the cursor location
        int cursor = _element.selectionStart;
        // get the string to be pasted
        String pasteString = e.clipboardData.getData("Text");
        // truncate clipboard data if it is too long
        if(pasteString.length > _length - _element.selectionStart) {
          pasteString = pasteString.substring(0, _length - _element.selectionStart);
        }
        // get prefix of existing value, everything up to cursor
        String prefix = _element.value.substring(0,_element.selectionStart);
        // get suffix of existing value, everything after the suffx and the length of the paste string
        String suffix = "";
        if(pasteString.length < _length - cursor) {
          suffix = _element.value.substring(_element.selectionStart + pasteString.length);
        }
        // set new contents value
        _element.value = "$prefix$pasteString$suffix";
        // stop paste action from going through
        // NOTE we only strictly need to do this if clipboard contents are too long for input,
        // NOTE but it is simpler to do it for both cases
        e.preventDefault();
        // restore cursor
        _element.selectionEnd = _element.selectionStart = cursor;
      });
      _element.onCut.listen((Event e) {
        // create a string of spaces the same length as the text that will be cut
  
negative.code:           }
          } else if(e.which == 46) {
            // don't do anything if cursor is at the end
            if(_element.selectionStart != _element.maxLength) {
              // insert a space after the character that will be deleted by the delete
              _element.setRangeText(" ", _element.selectionStart+1, _element.selectionStart+1);
            }
  