diff options
author | Yaksh Bariya <yakshbari4@gmail.com> | 2024-03-21 17:35:16 +0530 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarIT.de> | 2024-04-08 09:07:45 +0200 |
commit | 9f5268b4a726f6e2c38dcf24f1bd6a834fa171be (patch) | |
tree | 67014011db4a584d91730df272bfca18c5be87fa /searx/static/themes/simple/src | |
parent | 8bf2da9ce5cc9ef56d3cfd7c62c79cfa3f8e0c05 (diff) | |
download | searxng-9f5268b4a726f6e2c38dcf24f1bd6a834fa171be.tar.gz searxng-9f5268b4a726f6e2c38dcf24f1bd6a834fa171be.zip |
[enh] add keybindings for copying URLs
'y': for in Vim-mode (yank)
'c': for SearXNG-mode (copy)
This should help keyboard heavy users
Diffstat (limited to 'searx/static/themes/simple/src')
-rw-r--r-- | searx/static/themes/simple/src/js/main/keyboard.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/searx/static/themes/simple/src/js/main/keyboard.js b/searx/static/themes/simple/src/js/main/keyboard.js index d29518358..1fb12cae1 100644 --- a/searx/static/themes/simple/src/js/main/keyboard.js +++ b/searx/static/themes/simple/src/js/main/keyboard.js @@ -63,6 +63,12 @@ searxng.ready(function () { des: 'remove focus from the focused input', cat: 'Control' }, + 'c': { + key: 'c', + fun: copyURLToClipboard, + des: 'copy url of the selected result to the clipboard', + cat: 'Results' + }, 'h': { key: 'h', fun: toggleHelp, @@ -174,6 +180,12 @@ searxng.ready(function () { des: 'select next search result', cat: 'Results' }, + 'y': { + key: 'y', + fun: copyURLToClipboard, + des: 'copy url of the selected result to the clipboard', + cat: 'Results' + }, }, baseKeyBinding) } @@ -435,6 +447,14 @@ searxng.ready(function () { } } + function copyURLToClipboard () { + var currentUrlElement = document.querySelector('.result[data-vim-selected] h3 a'); + if (currentUrlElement === null) return; + + const url = currentUrlElement.getAttribute('href'); + navigator.clipboard.writeText(url); + } + searxng.scrollPageToSelected = scrollPageToSelected; searxng.selectNext = highlightResult('down'); searxng.selectPrevious = highlightResult('up'); |