I am making a coding assistant program, and I want to make it so that after a user presses the space bar, if the last word typed is one that the program recognizes, it will turn it to the color specified.

Basically, I want to do syntax highlighting. If there is any easier way than this please tell me, or else post some code.