Skip to content

Instantly share code, notes, and snippets.

@karakufire
Last active October 22, 2020 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karakufire/d2d7fa4f5b53767fa0d021a35ac579f5 to your computer and use it in GitHub Desktop.
Save karakufire/d2d7fa4f5b53767fa0d021a35ac579f5 to your computer and use it in GitHub Desktop.
weblio 英和和英辞典 フォーカス操作ユーティリティ
(function() {
'use strict';
document.querySelector('input#searchWord').focus();
document.addEventListener('keydown', e => {
if(e.isComposing || e.keyCode == 229);
else if(e.isComposing || e.keyCode === 27) document.querySelector('input#searchWord').blur();
return;
});
document.addEventListener('keyup', e => {
if(e.isComposing || e.keyCode === 229);
else if(e.isComposing || e.keyCode === 13) if(!document.querySelector('input#searchWord').hasFocus) document.querySelector('input#searchWord').focus();
return;
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment