How can I get the search form to be selected automatically?

This question is more suited to being asked on Stack Overflow as it is not a WordPress specific question, but here’s a solution for you anyway:

This makes no assumptions about the code controlling the existing functionality on the site, so there might be other ways that are more practical to hook into this process but for now here is an event listening that listens for a click on the “search button”, then after waiting 200 miliseconds, the callback function provided to setTimeout will focus the cursor onto the input field that is shown when the search container overlays the full-screen.

!(function($){
    $(function(){
        $('.search-button').on('click', function(event) {
            setTimeout( function() {
                $('.search-form-input').focus();
            }, 200)
        });
    });
})(jQuery);

error code: 523