added key event up and down arrows to controller.number.js

This commit is contained in:
Jono Brandel 2011-01-31 12:25:57 -08:00
parent 0a220426e9
commit 109474c99c

View File

@ -62,6 +62,20 @@ var NumberController = function() {
clickedNumberField = true;
document.addEventListener('mousemove', dragNumberField, false);
}, false);
// Handle up arrow and down arrow
numberField.addEventListener('keyup', function(e) {
switch(e.keyCode) {
case 38: // up
var newVal = _this.getValue() + step;
_this.setValue(newVal);
break;
case 40: // down
var newVal = _this.getValue() - step;
_this.setValue(newVal);
break;
}
}, false);
document.addEventListener('mouseup', function(e) {
document.removeEventListener('mousemove', dragNumberField, false);