code: function( containerNode, preceding, following )
      {
          if( window.getSelection )
          {
              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);
              }
          }
          else if( document.selection )
          {
              var sel = document.selection;
              if( sel.type != 'Control' )
              {
                  var range = sel.createRange();
                  range.collapse(true);
                  range.moveStart('character', -preceding);
                  range.moveEnd('character', following);
                  range.select();
              }
          }
      }
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