Last active
October 22, 2020 22:53
-
-
Save karakufire/d2d7fa4f5b53767fa0d021a35ac579f5 to your computer and use it in GitHub Desktop.
weblio 英和和英辞典 フォーカス操作ユーティリティ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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