javascript: capture CTRL+S

2019-04-05 00:00:00 IN1 , 2023-04-10 14:16:30 IN1


A cross-browser method to capture key combination CTRL+S with native JavaScript.

$(window).bind('keydown', function(event) {

    if (event.ctrlKey || event.metaKey) {

        switch (String.fromCharCode(event.which).toLowerCase()) {

            case 's':
                event.preventDefault();
                console.log('capture: CTRL+S');

                // do your stuff...

                break;
        }
    }
});
This website uses Cookies to provide you with the best possible service. Please see our Privacy Policy for more information. Click the check box below to accept cookies. Then confirm with a click on "Save".