Is it possible to run a JavaScript function only when the cursor focus is in a specific textarea?
I want to perform an action on keypress of the enter
key, however I don't want this event listner to be in place just generally on the page, rather only when the cursor is in the textarea
I have (id is postcontent
)
As an example, the function I'm using is this:
function onEnter(){
if(characterCode == 13)
{
console.log("Enter pressed");
}
}
Just as a start while I work out the focus issue...
I also have jQuery at my disposal.