Navigate the UI using only keyboard

后端 未结 5 1573
故里飘歌
故里飘歌 2020-12-31 15:21

I\'m trying to navigate thru a list of records using only keyboard. When the page loads, the default \"focus\" should be on the first record, when the user clicks the down a

5条回答
  •  孤城傲影
    2020-12-31 15:55

    Here is the example what you could choose to do: http://plnkr.co/edit/XRGPYCk6auOxmylMe0Uu?p=preview

    
      
  • {{ record.name }}
  • This is the simplest approach I could think of. It binds a directive keyTrap to the body which catches the keydown event and $broadcast message to child scopes. The element holder scope will catch the message and simply increment or decrement the focusIndex or fire an open function if hitting enter.

    EDIT

    http://plnkr.co/edit/rwUDTtkQkaQ0dkIFflcy?p=preview

    now supports, ordered / filtered list.

    Event handling part has not changed, but now uses $index and also filtered list caching technique combined to track which item is getting focused.

提交回复
热议问题