Skip to content

Instantly share code, notes, and snippets.

@mcleary
Created April 13, 2016 16:20
Show Gist options
  • Save mcleary/ca6bd4597b48e25061022c01667fe295 to your computer and use it in GitHub Desktop.
Save mcleary/ca6bd4597b48e25061022c01667fe295 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Teste de Input</title>
</head>
<body>
<input id="textinput" type="text"></input>
<input id="textoutput" type"text"></input>
</body>
<script>
input = document.getElementById("textinput");
output = document.getElementById("textoutput");
input.addEventListener("keydown", function(event) {
possible_inputs = ['-'];
if(event.shiftKey) {
return;
}
// '-' == 189
// Ver tabela ASCII
if(event.keyCode == 189) {
output.value += '-';
}
});
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment