棱角分明的UI全局键绑定 [英] angular-ui global key bindings

查看:102
本文介绍了棱角分明的UI全局键绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用角UI键preSS模块开始,想知道是否有一种方法,使这些工作无论在哪里我置于体内全局快捷键。

I've started using the angular-ui keypress module and was wondering if there is a way to make global shortcut keys which work no matter where I'm placed within the body.

我试图连接我的UI-KEYDOWN身体,但因为它不是处于焦点中的关键事件不会被解雇了。

I've tried linking my ui-keydown to the body but as it's not in focus the key events are not fired.

例如:

<body ui-keydown="{'pageup':'nav_to($event, \'users\')'}">

我知道我可以只专注一个div并附加键绑定到,但是当我有一个表格会发生什么,我想在每个字段内访问所有的全局键绑定?

I know I could just focus a div and attach the key bindings to that but what happens when I have a form and I want to access all the global key bindings within each field?

推荐答案

在主应用程序控制器试试这个:

Try this in your main app controller:

    angular.element($window).on('keydown', function(e) {
        console.log(e);
    });

这篇关于棱角分明的UI全局键绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆