probably, I always assumed this forum is more about jQuery, not programming in general.
You "could" read the whole content of the input field/text area, split the whole string and check
the word with the highest index. Should work but that is the quick&dirty way I guess.
A better approach is maybe to scan each keycode into some buffer variable, compare the buffer with the word you are seeking for, and flush the buffer on a whitespace for instance.
Kind Regards