'How do I change the color of specific text in a contenteditable textarea

May someone please tell me how to get specifically set text to change color through Javascript in a textarea like a IDE does

<textarea placeholder="place code here">Put Scripts Here</textarea><script src="/editor/codelib.js"></script>


Solution 1:[1]

HTML

<textarea onkeyup="checkWord(this)"></textarea>

JavaScript

        function checkWord(word)
            {
                if (word.value == "hello" || "world") {
                    word.style.color='orange'
                } 
                else if (word.value == "!" || ".") {
                    world.style.color='red'
                }
                else {
                    word.style.color='#FFF'
                }
            }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lasse Lenting