# Save With Ctrl+S or Cmd+S in the Classic Editor

> Lets you press Ctrl+S (Cmd+S on a Mac) to save a draft or update a published post in the classic editor, instead of the browser's save dialog.

- Type: PHP
- Runs: Admin only
- Category: [Admin](https://wpide.com/library/category/admin/)
- Tags: admin, classic-editor, keyboard
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/ctrl-s-saves-classic-editor/

## Code

```php
add_action( 'admin_footer-post.php', 'wpide_ctrl_s_script' );
add_action( 'admin_footer-post-new.php', 'wpide_ctrl_s_script' );

if ( ! function_exists( 'wpide_ctrl_s_script' ) ) {
    function wpide_ctrl_s_script() {
        if ( function_exists( 'use_block_editor_for_post' ) && use_block_editor_for_post( get_post() ) ) {
            return; // The block editor already supports the shortcut.
        }
        ?>
        <script>
        ( function ( $ ) {
            function save( event ) {
                if ( ! ( event.ctrlKey || event.metaKey ) || 's' !== String( event.key ).toLowerCase() ) {
                    return;
                }
                event.preventDefault();
                var $draft = $( '#save-post:visible' );
                if ( $draft.length ) {
                    $draft.trigger( 'click' );
                } else if ( 'publish' === $( '#original_post_status' ).val() ) {
                    $( '#publish' ).trigger( 'click' );
                }
            }
            $( document ).on( 'keydown', save );
            $( document ).on( 'tinymce-editor-init', function ( e, editor ) {
                editor.on( 'keydown', save );
            } );
        } )( jQuery );
        </script>
        <?php
    }
}
```

## Notes

Unpublished posts are only saved as drafts, never published, by the shortcut.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Save With Ctrl+S or Cmd+S in the Classic Editor" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
