So I'm attempting to create an if/else statement, where the console logs a statement if the enter key is pressed and if the caret has a certain position in an input field. What I can't figure out is how to detect where the caret is positioned and then assign that to a variable.
I have tried
windows.getSelection()
But this doesn't appear to do anything. Does anyone know how to do this in Javascript?