JSFiddle - React, Tailwind, and code Playground

by lollero

HTML

<textarea></textarea>
<input type="text">

JavaScript

var exclude = $("textarea, input");

$('html').on("keydown", function( e ) {

    if ( e.keyCode == 32 && !exclude.is(':focus') ) {
       console.log( 'Space pressed outside input or text area' );
    }
    
});