Javascript - check if user is editing text input

Viewed 5115

Can you check if the user is editing a text field without editing anything? I want a function to be called when the user is in a text field and presses enter. I know it would work with a form.

Coffee:

$(document).keyup (e) -> 
  func()  if e.which is 13 and "user is in input field"

Javascript:

$(document).keyup(function(e) {
    if(e.which == 13 and "user is in input field") {
        func();
    }
});
5 Answers
Related