intel / webapps-scientific-calculator

Apache License 2.0
27 stars 33 forks source link

Cannot use the keyboard #1

Open rossburton opened 12 years ago

rossburton commented 12 years ago

I can't enter numbers of operators using my keyboard.

davidmaxwaterman commented 10 years ago

not sure what to do about this...

davidmaxwaterman commented 10 years ago

This app is designed for use with a touch screen, eg mobile phone, tablet, and laptop (eg Lenovo X1 Carbon). However, it would be nice to be able to get it working with a h/w keyboard; but I'm not sure how to do that exactly :

1) perhaps the lower lcd could be a text input element - would need to be styled appropriately in order to minimise visual impact 2) perhaps keyboard input could be captured by a hidden text input element, and so there would be no visual changes at all

asadpakistani commented 9 years ago

I do not require the scientific options. So I will do be doing it for my use case using the mousetrap library. If you find time before me feel free to do the whole mapping.

http://craig.is/killing/mice

asadpakistani commented 9 years ago

My current hack after including moustrap is:

    Calculator = new function() {
        Mousetrap.bind('0', function() {
            $('#button0').trigger('mousedown');
        });

        Mousetrap.bind('1', function() {
            $('#button1').trigger('mousedown');
        });

        Mousetrap.bind('2', function() {
            $('#button2').trigger('mousedown');
        });

        Mousetrap.bind('3', function() {
            $('#button3').trigger('mousedown');
        });

        Mousetrap.bind('4', function() {
            $('#button4').trigger('mousedown');
        });

        Mousetrap.bind('5', function() {
            $('#button5').trigger('mousedown');
        });

        Mousetrap.bind('6', function() {
            $('#button6').trigger('mousedown');
        });

        Mousetrap.bind('7', function() {
            $('#button7').trigger('mousedown');
        });

        Mousetrap.bind('8', function() {
            $('#button8').trigger('mousedown');
        });

        Mousetrap.bind('9', function() {
            $('#button9').trigger('mousedown');
        });

        Mousetrap.bind('.', function() {
            $('#buttondot').trigger('mousedown');
        });

        Mousetrap.bind('+', function() {
            $('#buttonadd').trigger('mousedown');
        });

        Mousetrap.bind('-', function() {
            $('#buttonsubtract').trigger('mousedown');
        });

        Mousetrap.bind('backspace', function() {
            $('#buttondelete').trigger('mousedown');
        });

        Mousetrap.bind('enter', function() {
            $('#buttonequal').trigger('mousedown');
        });

        Mousetrap.bind('c', function() {
            $('#buttonclear').trigger('mousedown');
        });

        Mousetrap.bind('*', function() {
            $('#buttonmultiply').trigger('mousedown');
        });

        Mousetrap.bind('/', function() {
            $('#buttondivide').trigger('mousedown');
        });

        this.localizer = null;
        this.parser = "";

This needs to be refactored in to a key map and single method.