Created
December 9, 2015 14:41
-
-
Save nidate/783087407b8eca62c3be to your computer and use it in GitHub Desktop.
HTMLドキュメント内のキーイベントをすべて受け取る
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
<html> | |
<script type="application/javascript"> | |
document.addEventListener('DOMContentLoaded', function(){ | |
var elem = document.querySelector('.input'); | |
document.addEventListener('keydown', function(e) { | |
elem.textContent += JSON.stringify(e); | |
e.preventDefault(); | |
}); | |
}); | |
</script> | |
<style> | |
.input { | |
width: 300px; | |
height: 300px; | |
background-color: lightgray; | |
} | |
</style> | |
<div class="input"> | |
</div> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment