From 6c3da26731dbbc02e0c79d0f8be64b83151b1805 Mon Sep 17 00:00:00 2001 From: Kevin Hoffman Date: Wed, 19 Oct 2016 16:42:53 -0600 Subject: [PATCH] Adding Page Navigation Using Arrow Keys --- src/directives/pagination/dirPagination.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/directives/pagination/dirPagination.js b/src/directives/pagination/dirPagination.js index a1a7265..5a1cf78 100644 --- a/src/directives/pagination/dirPagination.js +++ b/src/directives/pagination/dirPagination.js @@ -396,6 +396,25 @@ function isValidPageNumber(num) { return (numberRegex.test(num) && (0 < num && num <= scope.pagination.last)); } + + // Add Page Navigation Using Arrow Keys + $(window).on('keyup', function(e) { + if (e.keyCode == "39" ) { // Right Arrow + if (scope.pagination.current < scope.pagination.last ) { + scope.pagination.current = (scope.pagination.current + 1); + scope.setCurrent(scope.pagination.current); + scope.$apply(); + } + } + + if (e.keyCode == "37" ) { // Left Arrow + if (scope.pagination.current > 1 ) { + scope.pagination.current = (scope.pagination.current - 1); + scope.setCurrent(scope.pagination.current); + scope.$apply(); + } + } + }) } /**