This example creates a number of keystrokes and adds them to the input map of a component. When a keystroke is added to an input map, an action name must be supplied. This action is invoked when the keystroke is pressed while the component has the focus.

    // Create some keystrokes and bind them all to the same action
component.getInputMap().put(KeyStroke.getKeyStroke("F2"), "actionName");
component.getInputMap().put(KeyStroke.getKeyStroke("control A"), "actionName");
component.getInputMap().put(KeyStroke.getKeyStroke("shift F2"), "actionName");
component.getInputMap().put(KeyStroke.getKeyStroke('('), "actionName");
component.getInputMap().put(KeyStroke.getKeyStroke("button3 F"), "actionName");
component.getInputMap().put(KeyStroke.getKeyStroke("typed x"), "actionName");
component.getInputMap().put(KeyStroke.getKeyStroke("released DELETE"), "actionName");
component.getInputMap().put(KeyStroke.getKeyStroke("shift UP"), "actionName"); // Add the action to the component
component.getActionMap().put("actionName",
new AbstractAction("actionName") {
public void actionPerformed(ActionEvent evt) {
process(evt);
}
}
);
Related Examples

e858. 将键盘键和事件绑定的更多相关文章

  1. Geckofx 45 正确模拟键盘输入的事件绑定方法

    var inputs = selection.GetElementsByTagName("input").Select(p => p as Gecko.DOM.GeckoIn ...

  2. Dojo初探之4:dojo的event(鼠标/键盘)事件绑定操作(基于dojo1.11.2版本)

    前言: 上一章详解了dojo的dom/query操作,本章基于dom/query基础上进行事件绑定操作 dojo的事件 dojo的事件绑定操作分为鼠标和键盘两种进行详解 1.鼠标事件 我们沿用上一章中 ...

  3. js对键盘输入事件绑定到特定按钮

    转自:https://www.cnblogs.com/liluping860122/archive/2013/05/25/3099103.html<script type="text/ ...

  4. [转] js对键盘输入事件绑定到特定按钮。

    <script type="text/javascript" language="javascript"> document.onkeyup = f ...

  5. 捕获enter键盘事件绑定到登录按钮

    /** *捕获enter键盘事件绑定到登录按钮 */ function keyLogin(event) { if (event.keyCode == 13) { document.getElement ...

  6. js Dom为页面中的元素绑定键盘或鼠标事件

    html鼠标事件 onload 页面加载 onclick 鼠标单击 onmouseover 鼠标移入 onmouseout 鼠标移出 onfocus 获取焦点 onblur 失去焦点 onchange ...

  7. 通过键盘上下键 JS事件,控制候选词的选择项

    效果图 JS代码 //上下键 选择事件 searchBackgroud 为样式,只做标记,无实质样式,因为和其他样式不兼容,只能添加CSS $(document).keydown(function ( ...

  8. js 获取当前焦点所在的元素、给元素和input控件添加键盘监听事件、添加页面级的键盘监听事件

    页面级的键盘监听事件 document.onkeydown = function (event) { var e = event || window.event || arguments.callee ...

  9. dojo事件驱动编程之事件绑定

    什么是事件驱动? 事件驱动编程是以事件为第一驱动的编程模型,模块被动等待通知(notification),行为取决于外来的突发事件,是事件驱动的,符合事件驱动式编程(Event-Driven Prog ...

随机推荐

  1. 每日英语:China to Move Slowly on One-Child Law Reform

    BEIJING—China's family-planning agency is projecting a slow rollout for an easing of its one-child p ...

  2. Docker 构建网络服务后本机不能访问

    Docker 构建网络服务后本机不能访问 起因 使用tornado构建了一个服务,测试都没有问题 使用docker构建镜像,使用docker run image_name启动服务 使用浏览器访问 12 ...

  3. ffmpeg转码参数设置

    ffmpeg用了很久了,也没有想写点什么. 刚接触ffmpeg也是有大量的不理解的地方,不过慢慢的了解多了基本上都是可以使用的. 本文主要介绍如何使用ffmpeg.exe进行转码.编译好的ffmpeg ...

  4. js jquery 函数回调

    JS 函数回调 $('#btn_update').click(function () { var table_id = $table.bootstrapTable('getSelections')[0 ...

  5. TRUNC 截取日期或数字,返回指定的值。

    TRUNC(number,num_digits) Number 需要截尾取整的数字. Num_digits 用于指定取整精度的数字.Num_digits 的默认值为 0.   /*********** ...

  6. Cpu表现出正弦曲线

    #include <windows.h> #include <math.h> int main(void) { SetThreadAffinityMask(GetCurrent ...

  7. browser_autopwn2

    browser_autopwn2是个啥玩意儿? 一个集合了浏览器漏洞的小框架 option msf > use auxiliary/server/browser_autopwn2 msf aux ...

  8. xss绕过htmlspecialchars实体编码的姿势

    倘若是在script.input标签当中,即可突破.Payload ' oninput=alert`1` //      当要在input中输入内容时触发事件' oninput=alert`1` ' ...

  9. spring security 注解@EnableGlobalMethodSecurity详解

     1.Spring Security默认是禁用注解的,要想开启注解,需要在继承WebSecurityConfigurerAdapter的类上加@EnableGlobalMethodSecurity注解 ...

  10. 【Linux/CentOS】上手常见问题笔记

    场景:Web项目服务端想要运行在Linux系统上,还要编写一些自动化发布代码的Shell脚本,需要学习使用Linux系统. 环境:Windows系统下用虚拟机VMware Workstation Pr ...