1

I've managed to get enter keypress to work. But I can't seem to get the "shift" button keypress to work. Here is my code for enter:

<button 
    class="btn btn-primary order-input-add" 
    ui-keypress="{13:'add_plu(order.orderwindow.add_field)'}" 
    ng-click="add_plu(order.orderwindow.add_field)">Add
</button>
1

1 Answer 1

1

Since it seems that you can't capture a shift key press by itself using ui.keydown (if so, probably because it's most often used as a modifier key), you can instead create your own directive that decorates an element to listen for shift on the keydown event:

angular.module('myApp', [])
.directive('captureShift', function(){
  return {
    restrict: 'A',
    link: function(scope, elem, attrs) {
      elem[0].onkeydown = function(){
        console.log('shift pressed');
      }
    }
  }
});

Shift doesn't seem to fire on keypress but does on keydown, so onkeydown is used.

Plunker Demo

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.