0

Hi! I was wondering how to use the tab button on the keyboard to call a function? Something like this:

<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>

This code segment allows me to press "enter" to call function "add_plu()". This uses angular ui utility library.

Thanks

2
  • Doesn't work. Tried it. Commented May 5, 2014 at 0:47
  • 1
    What about if you use ui-keydown instead of ui-keypress?
    – aet
    Commented May 5, 2014 at 0:57

1 Answer 1

2

The keypress event is fired when a key is pressed down and that key normally produces a character value.

You can use the keydown event instead:

ui-keydown="{ 'tab':'add_plu(order.orderwindow.add_field)'}"

Demo: http://plnkr.co/edit/XMRlVLnw2BEyoVgvQyW9?p=preview

Note that you need to click the button first to give it focus, which is another issue.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.