Publish.js code snippet for slash key quick search functionality

If anyone was missing the “jump to search” with the slash key function in obsidian publish, I created a snippet you can add to the publish.js file that adds this feature.

code/example can be found here

I am glad you posted a link instead of just pasting the snippet. Now we all get to see that wonderful 404 page.

Is this something like you had in mind? I cut through your publish.js to find these important parts:

// Smack that slash button, go to search bar.
function expandLeftSidebar() {

function collapseLeftSidebar() {
    search.blur(); // removes keyboard focus (js is dumb for choosing the word blur for this)

function checkShortcuts(event) {
    if (event.keyCode == 191) { // SLASH KEY
        return false;
    if (event.keyCode == 27) { // ESC KEY
        return false;

document.onkeydown = checkShortcuts;
var search = document.getElementsByClassName("search-bar")[0];

Hey, sorry about that, my bad! I’m reorganizing stuff a bunch right now. The code is here:

rokosphoenix/publish.js at main · harttraveller/rokosphoenix (