Fix Konami Code in Firefox with Quick Find

Fixes https://github.com/1j01/jspaint/issues/111
main
Isaiah Odhner 2018-04-18 23:13:23 +00:00
parent 3afc3d29cb
commit d7077334d1
1 changed files with 9 additions and 0 deletions

View File

@ -15,6 +15,15 @@ var Konami = {};
if (matchedKey) {
index += 1;
// fix for Firefox with "Search for text when you start typing" enabled
// https://support.mozilla.org/en-US/kb/search-contents-current-page-text-or-links
// prevent the default (opening Quick Search) for B and A,
// which are luckily at the end of the Konami Code sequence
// (otherwise it could prevent typing A and B in text fields unwantedly)
if (event.keyCode === 66 || event.keyCode === 65) {
event.preventDefault();
}
if (index === sequence.length) {
// reset when sequence completed