onkeyup - jquery: do this on keyup, unless the person is in a textarea or input -


my script works don't understand how make not launch functions when in textarea/input , keys pressed. aka: launch event when user presses key, unless user in textarea/input.

$('body').keyup(function (event) {  var direction = null; if (event.keycode == 37) {   $('#wrapper').fadeout(500) } else if (event.keycode == 39) {         $('html,body').animate({scrolltop: $('body').offset().top}, {duration: 1500, easing: 'easeinoutquart'}         ) return false;     }      }) 

just check event.target:

$('body').keyup(function(event) {     if ($(event.target).is(':not(input, textarea)')) {        ...     } }); 

in case still have 1 event handler (attached body) filter elements recieves event


Comments

Popular posts from this blog

unicode - Are email addresses allowed to contain non-alphanumeric characters? -

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -