I have set up keyboard event listeners for the left, right, and esc keys.
Each key is associated with a function in the controller that should update some scope variables.
Although the functions are being triggered when the keys are pressed, it appears that the scope variables are not being updated as expected.
Could this be due to a scope issue? Is there a problem with binding these events to the body
element?
angular.element( document.body ).bind('keydown keypress', function (event)
{
if(event.which === 27) // 27 = esc key
{
$scope.toggleSize();
// $scope.$apply(function() {
// $scope.fullscreen = !$scope.fullscreen;
// });
console.log('scope', $scope.fullscreen);
event.preventDefault();
} else if(event.which === 37) {
console.log('next');
$scope.goToNextSection('currentSection', $scope.slides);
} else if(event.which === 39) {
console.log('prev');
$scope.goToPreviousSection('currentSection', $scope.slides);
}
});