문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top