Theys96/hugo-fuse-search

feature? is it easy to change the key combo that shows the search box?

Opened this issue · 3 comments

Is it possible to change from cmd+/ to something like Ctrl+S

I'm looking at selenium and automated testing but currently I cant get it to send keys cmd+/

I would like to make it possible -but I'm not sure how yet- to configure the Javascript from the config.yml. There are multiple ways to do this.

Ctrl+S is reserved for saving though, but you can change this snippet:

// This component is controlled with the keyboard:
keyboardHandler(e, component) {
if (event.metaKey && event.which === 191) { // Cmd + /
component.initSearch();
} else {
switch(e.keyCode) {
case 27: // ESC
component.closeSearch();
break;
case 40: // DOWN
component.navigateDown(e);
break;
case 38: // UP
component.navigateUp(e);
break;
}
}
}

To trigger initSearch() with -say- the . key:

    // This component is controlled with the keyboard:
    keyboardHandler(e, component) {
        if (event.metaKey && event.which === 191) { // Cmd + /
            component.initSearch();
        } else {
            switch(e.keyCode) {
                case 46: // PERIOD
                    component.initSearch();
                    break;

                case 27: // ESC
                    component.closeSearch();
                    break;

                case 40: // DOWN
                    component.navigateDown(e);
                    break;

                case 38: // UP
                    component.navigateUp(e);
                    break;
            }
        }
    }

This is now a part of issue #9 .

PR #10 added unit testing. It runs automatically on Travis CI. I propose we use these tests alongside your Selenium testing.