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. [AWS vs Azure] 云计算里AWS和Azure的探究(3)

    云计算里AWS和Azure的探究(3) ——Amazon EC2 和 Windows Azure Virtual Machine 今天我来比较一下AWS EC2和Azure VM的具体流程上的异同.以 ...

  2. 每日英语:KFC's Crisis in China Tests Ingenuity of Man Who Built Brand

    Sam Su for years ran one of the highest-flying foreign business operations in China. These days, he' ...

  3. tensorflow笔记3:CRF函数:tf.contrib.crf.crf_log_likelihood()

    在分析训练代码的时候,遇到了,tf.contrib.crf.crf_log_likelihood,这个函数,于是想简单理解下: 函数的目的:使用crf 来计算损失,里面用到的优化方法是:最大似然估计 ...

  4. 远程mysql导入本地文件

    远程mysql导入本地文件 登陆数据库 mysql --local-infile -h<IP> -u<USR> -p 选择数据库 USE xxx 导入文件 LOAD DATA ...

  5. Android开发(九)——ViewFlipper实现图片轮播

    图片轮播的实现方法有很多,主要有View.ViewFilpper.ViewFilpper系统自带的一个多页面管理控件,它可以实现子界面的自动切换. 首先 需要为ViewFlipper加入View (1 ...

  6. MySQL 中联合查询效率分析

    目前我有两个表,一个keywords和一个news表.keyword存放关键词是从news中提取,通newsid进行关联,两表关系如图: keywords中存有20万条数据,news中有2万条数据,现 ...

  7. 使用Android Studio进行NDK开发

    Step1:创建native方法 很easy,仅仅须要给定义好的方法加上native关键词就可以 注意:由于该方法的详细实现是在c++中详细实现的.所以相似于接口方法不须要加{}. Step2:生成c ...

  8. mysql hive sql 进阶

    场景: 说明.1.上面的数据是经过规整的数据,step是连续的,这个可以通过row_number实现.连续是必要的一个条件因为在计算第二个查询条件时依赖这个顺序,如果step不是数字字段可以截取然后转 ...

  9. C语言 · 最长公共子序列 · 最长字符序列

    算法提高篇有两个此类题目: 算法提高 最长字符序列   时间限制:1.0s   内存限制:256.0MB      最长字符序列 问题描述 设x(i), y(i), z(i)表示单个字符,则X={x( ...

  10. u-boot2016.05 有关 4096page size , oob == 224 nand 的移植支持

    大致介绍一下这个 nand 的基础属性 pagesize == 4096 byte oob == 224 byte block size == 256 Kbyte u-boot configs/xxx ...