Sg 2.9
KeyEvent
Packages RSS
About
News
Gallery
Scripts
Tutorials
Download
Reference
Forum
Users
License
Twitter

The KeyEvent object is received by the key event handlers onKeyDown(event) and onKeyUp(event). The KeyEvent object is the only parameter passed to these functions and contains information about the key event.

Sample code:

function onKeyDown(event) {
	// The character of the key that was pressed
	print(event.character);
}

Properties

Specifies the type of key event. Read-only.

    Returns:
  • String ('keydown', 'keyup') — the type of key event.
key

Specifies the identifier of the key that caused this key event. Read-only.

    Returns:
  • String ('command', 'enter', 'return', 'backspace', 'tab', 'cancel', 'clear', 'shift', 'control', 'alt', 'option', 'pause', 'caps-lock', 'escape', 'space', 'page-up', 'page-down', 'end', 'home', 'left', 'up', 'right', 'down', 'comma', 'minus', 'period', 'slash', 'num-0', 'num-1', 'num-2', 'num-3', 'num-4', 'num-5', 'num-6', 'num-7', 'num-8', 'num-9', 'semicolon', 'equals', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'open-bracket', 'close-bracket', 'backslash', 'numpad-0', 'numpad-1', 'numpad-2', 'numpad-3', 'numpad-4', 'numpad-5', 'numpad-6', 'numpad-7', 'numpad-8', 'numpad-9', 'multiply', 'add', 'separator', 'subtract', 'decimal', 'divide', 'delete', 'num-lock', 'scroll-lock', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f11', 'f12', 'print-screen', 'insert', 'help', 'meta', 'back-quote', 'quote', 'kp-up', 'kp-down', 'kp-left', 'kp-right', 'dead-grave', 'dead-acute', 'dead-circumflex', 'dead-tilde', 'dead-macron', 'dead-breve', 'dead-above-dot', 'dead-diaeresis', 'dead-above-ring', 'dead-double-acute', 'dead-caron', 'dead-cedilla', 'dead-ogonek', 'dead-iota', 'dead-voiced-sound', 'dead-semivoiced-sound', 'ampersand', 'asterisk', 'quotedbl', 'less', 'greater', 'brace-left', 'brace-right', 'final', 'convert', 'non-convert', 'accept', 'mode-change', 'kana', 'kanji', 'alphanumeric', 'katakana', 'hiragana', 'full-width', 'half-width', 'roman-characters') — the key identifier.

Specifies the String character of the key that caused this key event. Read-only.

    Returns:
  • char — the key character.

Returns an object representing the state of various modifiers keys. These properties are supported: shift, control, option, meta, capsLock.

Sample code:

function onMouseDown(event) {
 if(event.modifiers.shift) {
 	print('The shift key is down');
 };
}
Read-only.

AltStyle によって変換されたページ (->オリジナル) /