Last active
August 29, 2015 14:10
-
-
Save coryk135/df9914cc68dee4f18d3b to your computer and use it in GitHub Desktop.
[wearscript] Key Input
This file contains hidden or 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> | |
<head> | |
<!-- You can include external scripts here like so... --> | |
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/zepto/1.0/zepto.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>--> | |
<style> | |
html, body { width: 100%; height 100%; overflow: hidden; margin: 0; background-color: black; } | |
</style> | |
</head> | |
<body> | |
<p style="font-size: 3.2em; color: white" id="output">hi</p> | |
<script> | |
var str = ''; | |
var out = document.querySelector('#output'); | |
document.addEventListener('keydown', function(ev){ | |
if(ev.keyCode == 8) { | |
str = str.substr(0,str.length-1); | |
} | |
out.textContent = str; | |
}); | |
document.addEventListener('keypress', function(ev){ | |
str += String.fromCharCode(ev.keyCode); | |
out.textContent = str; | |
}); | |
window.onload = main; | |
function main() { | |
if (WS.scriptVersion(1)) return; | |
WS.serverConnect('{{WSUrl}}', serverConnected); | |
} | |
function serverConnected() { | |
WS.sound('SUCCESS'); | |
} | |
</script> | |
</body> | |
</html> |
This file contains hidden or 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
{"name":"Example"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment