I have a contenteditable div. What I'm trying to do is make it so that if the user types the @
symbol, it (on keypress) changes the colour of the text (including the @
symbol) until the next space.
For example, imagine that the bold text is the coloured text:
"Here is some @sample text."
Here's the JSFiddle I started, but I don't know how to carry on from it: http://jsfiddle.net/p8WsT/4/
HTML:
<div class="typeable" contenteditable="true">Type "@test" after this text: </div>
JS:
$(document).on("keydown", ".typeable", function(event) {
event.preventDefault();
var code = event.keyCode; // code 50 is @
});
Please help!