Forum Settings
Forums
New
Feb 26, 10:07 AM
#1

Offline
Jan 2022
3
I have written a script to key bind the search bar. Having a habit of using a keyboard only prompted me to do this.
To use this download the extension TamperMonkey.
Create a new script, paste this code, and save it.

// ==UserScript==
// @name         Search Bar Keybind
// @namespace    http://tampermonkey.net/
// @version      2024-02-26
// @description  Keybind for search bar
// @author       You
// @match        https://myanimelist.net/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    document.addEventListener('keydown', function(event) {
    if (event.key === '/' && !(document.activeElement.tagName.toLowerCase() === 'input' || document.activeElement.tagName.toLowerCase() === 'textarea')) {
         {
            event.preventDefault();

            var searchInput = document.getElementById('topSearchText');
            if (searchInput) {
                searchInput.focus();
            }
        }
    }
});
})();


This binds forward slash (/) as a key bind to focus the search bar while not highlighting when it is typed in a text area or input box. I realized this problem while writing this post.
If you want to change the key bind you can edit the button in this line :

if (event.key === '/' && !(document.activeElement.tagName.toLowerCase() === 'input' || document.activeElement.tagName.toLowerCase() === 'textarea')) {

Please use and let me know if there are any bugs also if you prefer to use combination key binds let me know and I will make an edit for you.

More topics from this board

» @ sign spam/attack

kuroneko99 - Apr 16

4 by traed »»
8 hours ago

» Add the option to change profile favorites pictures

k1rb - Oct 21, 2022

20 by Astachanna »»
8 hours ago

» An "Anime Franchise" page

_cjessop19_ - Today

1 by Astachanna »»
8 hours ago

» Combining every season of an Anime?

Dennisss - Apr 1, 2021

17 by _cjessop19_ »»
Today, 1:08 AM

Poll: » Add list setting to make notes private (on public lists)

S_h_a_r_k_93 - Nov 12, 2022

25 by anonymate »»
Apr 24, 9:57 PM
It’s time to ditch the text file.
Keep track of your anime easily by creating your own list.
Sign Up Login