code: function( containerNode, preceding, following )
      {
          var sel = window.getSelection();
          if( sel.modify )
          {
              for( var i=0; i < preceding; ++i )
                  sel.modify('extend', 'backward', 'character');
              for( var i=0; i < following; ++i )
                  sel.modify('extend', 'forward', 'character');
          }
          else
          {
              // not so easy if the steps would cover multiple nodes ...
              var range = sel.getRangeAt(0);
              range.setStart( range.startContainer, range.startOffset - preceding );
              range.setEnd( range.endContainer, range.endOffset + following );
              sel.removeAllRanges();
              sel.addRange(range);
          }
      }
docs: http://stackoverflow.com/questions/15157435/get-last-character-before-caret-position-in-javascript http://stackoverflow.com/questions/11247737/how-can-i-get-the-word-that-the-caret-is-upon-inside-a-contenteditable-div