1
0
mirror of https://github.com/GTFOBins/GTFOBins.github.io.git synced 2024-09-20 10:53:35 +02:00

Clear filter by pressing escape

This commit is contained in:
Andrea Cardaci 2018-05-29 12:10:30 +02:00
parent a108890c1f
commit 4093161262

View File

@ -66,12 +66,19 @@
filter(query); filter(query);
}); });
// focus search box on keydown // handle shortcuts
addEventListener('keydown', function (event) { addEventListener('keydown', function (event) {
// focus search box on valid keydown
if (event.key.toLowerCase().match(/^[\/a-z]$/) && if (event.key.toLowerCase().match(/^[\/a-z]$/) &&
!(event.ctrlKey || event.altKey || event.metaKey)) { !(event.ctrlKey || event.altKey || event.metaKey)) {
searchBox.focus(); searchBox.focus();
} }
// clear filter on escape
else if (event.key === 'Escape') {
searchBox.value = '';
searchBox.focus();
filter('');
}
}); });
// filter on load according to the URL // filter on load according to the URL