1
0
Fork 0

Added keybindings for calculator usage

This commit is contained in:
Joe L. Wroten 2015-11-01 22:51:25 -06:00
parent 2f38fdb634
commit 7ebbacf3ac

38
app.js
View file

@ -1,9 +1,5 @@
$(document).ready(function() {
// This command is used to initialize some elements and make them work properly
$.material.init();
});
new Vue({
var App = new Vue({
el: '#calculator',
data: {
result: 0,
@ -40,3 +36,35 @@ new Vue({
}
}
});
$(document).ready(function() {
// This command is used to initialize some elements and make them work properly
$.material.init();
// Key Bindings
$(document).on('keypress', function(event) {
switch (event.keyCode) {
case 61: // =
case 13: // Enter
App.equals();
break;
case 47: // / (Forward Slash... haha)
App.calcAdd('/');
break;
case 42: // *
case 120: // x
App.calcAdd('*');
break;
case 45: // -
App.calcAdd('-');
break;
case 43: // +
App.calcAdd('+');
break;
default:
if (event.keyCode >= 48 && event.keyCode <= 57) {
App.calcAdd(event.keyCode - 48);
}
}
});
});