Keyboard Shortcut to Edit a Page/Post in WordPress

WordPress does have a toolbar for logged-in administrators, but I often like to keep this feature disabled so while I’m viewing the site, I see it like normal visitors do. It’s nice to have a quick way to edit the page you’re currently viewing though.

Here’s a way to allow the Ctrl+; keyboard combination to edit the current page. You can change it to a different combination if you prefer, but this seems to be a good one because most web browsers don’t use that as a keyboard shortcut for their own functionality. (For example, the more obvious Ctrl+e shortcut is used by Chrome to focus the address bar.)

The basic idea is to output <link rel="edit-form"> links in the page’s <head> pointing to the WordPress backend editor, then use some Javascript to capture the keyboard combination and redirect to that link. (rel="edit-form" is defined in RFC 6861.)

Here’s the code to add to your theme. (Or you could bundle it up into a plugin, I guess.)