From a065e04d529da1d847b5062a12c46d916408bf32 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 21:46:22 -0500 Subject: update based on https://github.com/mdn/yari/issues/2028 --- files/zh-cn/mozilla/tech/xul/key/index.html | 166 ---------------------------- 1 file changed, 166 deletions(-) delete mode 100644 files/zh-cn/mozilla/tech/xul/key/index.html (limited to 'files/zh-cn/mozilla/tech/xul/key/index.html') diff --git a/files/zh-cn/mozilla/tech/xul/key/index.html b/files/zh-cn/mozilla/tech/xul/key/index.html deleted file mode 100644 index 13fabfbd2d..0000000000 --- a/files/zh-cn/mozilla/tech/xul/key/index.html +++ /dev/null @@ -1,166 +0,0 @@ ---- -title: key -slug: Mozilla/Tech/XUL/key -tags: - - XUL Elements - - XUL Reference -translation_of: Archive/Mozilla/XUL/key ---- -
- - « XUL Reference home [ - 示例 | - 属性 | - 特性 | - 方法 | - 相关 ] -
-

The key element defines a keyboard shortcut. Event handlers can be used to respond when the appropriate keys are pressed. A key element must be placed inside a keyset element.

-

When a key matching the attributes on the key element is pressed, the command will be fired on the key element. The key pressed must match the key attribute (or keycode attribute) as well as the modifiers attribute in order for the key element to be activated and fire a command event.

-

For example, consider the following key:

-
<key key="r" modifiers="shift"/>
-
-

This key will only match when the Shift key is pressed as well as the R key, and no other keys. For instance, if the Shift, Control and R keys are all pressed, the key will not match.

-

To indiciate that a modifier key may optionally be pressed, place the word 'any' after listing the optional modifier key. For example:

-
<key key="r" modifiers="shift any control"/>
-
-

In this example, the shift key may or may not be pressed, while the control key must be pressed. This allows keys to match more loosely for modifier keys that aren't relevant, yet still allows specific modifiers to be required.

-

If the modifiers attribute is not specified, then no modifiers may be pressed for the key to match.

-

If neither the key or keycode attribute are used, the key element will handle all key events. However, if one of the attributes is set to an empty string, the element doesn't handle any key events. For example:

-
<!-- This element handles all key events -->
-<key/>
-
-<!-- These elements don't handle any key events -->
-<key key="" modifiers="control"/>
-<key keycode="" modifiers="control"/>
-
-

More information is available in the XUL tutorial.

-
-
- Attributes
-
- command, disabled, key, keycode, keytext, modifiers, oncommand, phase
-
-

Examples

-

(example needed)

-

Attributes

-

- -
-
- command
-
- Type: - - element id -
-
- Set to the id of a command element that is being observed by the element.
-
- -

-
- - -
-
disabled
-
 
-
-
类型:boolean
-
-
-
表示元素是被禁用的。
- -

如果这个元素的disabled属性被设置为true,表示元素被禁用,被禁用的属性在页面上通常会显示灰色文本,它无法响应用户的操作,它也无法得到光标。

- -

然而,这个元素仍然能够响应鼠标事件,如果要启用这个元素,把disabled设置为false

-
-
- -

示例:

- -
Image:XUL_ref_attr_disabled.png
- -
// Disabling an element
-document.getElementById('buttonRemove').setAttribute("disabled", "true");
-
-// Enabling back an element by removing the "disabled" attribute
-document.getElementById('buttonRemove').removeAttribute("disabled");
- -

-

Firefox 3.5 note

-

For keyset elements, support for this attribute was added in Firefox 3.5.

-

-
- - -
-
key
-
Type: character
-
The character that must be pressed. This should be set to a displayable character.
-
-
- - -
-
keycode
-
Type: string key code
-
For keys that do not have displayable characters, such as the Enter key or function keys, use this attribute instead of the key attribute. Valid keys are listed at Keyboard Shortcuts.
-
-
- - -
-
keytext
-
Type: string
-
A label for the keyboard shortcut. This text would appear next to a menuitem label if that menuitem is associated with the key element via its key attribute.
-
-
- - -
-
modifiers
-
Type: space-separated list of the values below
-
A list of modifier keys that should be pressed to invoke the keyboard shortcut. Multiple keys may be separated by spaces or commas. Keys will map to other keys on platforms that do not have them.
-
- - -
- - -
-
oncommand
-
Type: script code
-
This event handler is called when the command is activated. This occurs when a user selects a menu item or presses a keyboard shortcut attached to the command.
-
- - -
- - -
-
phase
-
Type: string
-
The event phase where the handler is invoked. This should be set to the value capturing to indicate during the event capturing phase or target to indicate at the target element or left out entirely for the bubbling phase.
-
-

-

Properties

-

-

Inherited Properties
align, , allowEvents, , boxObject, builder, , , , className, , , , , collapsed, contextMenu, controllers, database, datasources, dir, , , flex, height, hidden, id, , , left, , maxHeight, maxWidth, menu, minHeight, minWidth, , , , , , , observes, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statusText, style, ,, tooltip, tooltipText, top, width

-

Methods

-

-

Inherited from XUL element
blur, click, doCommand, focus, getElementsByAttribute

Inherited from DOM element
addEventListener(), appendChild(), dispatchEvent(), getAttribute(), getAttributeNode(), getAttributeNodeNS(), getAttributeNS(), getElementsByTagName(), getElementsByTagNameNS(), hasAttribute(), hasAttributeNS(), hasAttributes(), hasChildNodes(), insertBefore(), isSupported(), normalize(), removeAttribute(), removeAttributeNode(), removeAttributeNS(), removeChild(), removeEventListener(), replaceChild(), setAttribute(), setAttributeNode(), setAttributeNodeNS(), setAttributeNS()

- -

TBD

-
-  
-

-- cgit v1.2.3-54-g00ecf