I’m programming an online editor. To get character inputs correctly I’m using jQuery.onKeyPress event on a textarea element (getting inputs from the body doesn’t work, as characters such as backspace activate certain browser shortcuts – also, some characters are only provided correctly this way). That textarea is hidden by positioning it outside the window (otherwise won’t work).
Questions are:
- Is there a better design for what I’m doing?
- How can I guarantee that this element is never defocused, other than setting a timer to focus it constantly?
To make sure the element is always in focus, use this: