JavaScript语言参考手册      
JavaScript手册
【目录】 【上一页】 【下一页】 【索引】

onKeyPress

Executes JavaScript code when a KeyPress event occurs; that is, when the user presses or holds down a key.

事件适用对象document, Image, Link, Textarea
实现版本Navigator 4.0

语法

onKeyPress="handlerText"

参数

handlerTextJavaScript 代码或对一个 JavaScript 函数的调用。

使用的事件属性

type标明了事件的类型。
target标明了事件原来发送的对象。
layerX, layerY,
pageX, pageY,
screenX, screenY
For an event over a window, these represent the cursor location at the time the event occurred. For an event over a form, they represent the position of the form element.
whichRepresents the ASCII value of the key pressed. To get the actual letter, number, or symbol of the pressed key, use the String.fromCharCode 方法。 To set this 属性 when the ASCII value is unknown, use the String.charCodeAt 方法。
modifiersContains the list of modifier keys held down when the event occurred.

描述

A KeyPress event occurs immediately after a KeyDown event only if onKeyDown returns something other than false. A KeyPress event repeatedly occurs until the user releases the key. You can cancel individual KeyPress events.

参看

onKeyDown, onKeyUp

要获得关于事件句柄的常规信息,请看“事件的常规信息”

要获得关于事件对象的信息,请看事件


【目录】 【上一页】 【下一页】 【索引】

返回页面顶部

JavaScript中文手册 站长在线 整理