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. git提交本地代码到新分支

    背景: 从branchA分支拉了一份代码,做了一些修改,但是不想提交到branchA分支,想新建一个分支branchB保存代码. 操作方法: 添加本地需要提交代码 git add . 提交本地代码 g ...

  2. 【Mysql】Fedora下 Mysql 安装及配置

    1.安装 Mysql Server # yum install mysql mysql-server 可以到mysql官网去下载,我下载的是通用版本.你需要下载下面四个文件就可以了. mysql-cl ...

  3. js模板引擎art-template使用方法

    art-template是款性能卓越的 js 模板引擎 https://aui.github.io/art-template/ 特性 拥有接近 JavaScript 渲染极限的的性能 调试友好:语法. ...

  4. Lintcode: Implement Queue by Stacks 解题报告

    Implement Queue by Stacks 原题链接 : http://lintcode.com/zh-cn/problem/implement-queue-by-stacks/# As th ...

  5. 【Bayesian】贝叶斯决策方法(Bayesian Decision Method)

    已知某条件概率,如何得到两个事件交换后的概率,也就是在已知P(A|B)的情况下如何求得P(B|A).这里先解释什么是条件概率: 表示事件B已经发生的前提下,事件A发生的概率,叫做事件B发生下事件A的条 ...

  6. wamp安装xdebug特殊情况win7 64位安装32位wamp

    在wamp上安装xdebug网上很多文章都介绍了方法,但是我这里遇到了一个很特殊的情况,在网上很少有人提及: 我机器是win7 64位的,安装的wamp1.7.4是32位的,这是后来导致出现奇怪现象的 ...

  7. hadoop 大数据 介绍

    1.Hadoop是一个大家族,是一个开源的生态系统,是一个分布式运行系统,是基于Java编程语言的架构.不过它最高明的技术还是HDFS和MapReduce,使得它可以分布式处理海量数据. 2.HDFS ...

  8. python获取软件安装列表2222

    softer_installed_list ===================== 使用python编写的,获取本机软件安装列表,输出为html表格. * win7 32位环境下运行 * 使用的是 ...

  9. ubuntu 安装redis

    1. 下载安装: cd /tmp wget http://redis.googlecode.com/files/redis-2.2.4.tar.gz tar -zxf redis-2.2.4.tar. ...

  10. java中unicode和中文相互转换

    package test.com.gjob.services; import java.util.Properties; public class Test { public static void ...