A keystroke for use with keyboard shortcuts.

This class extends BiObject and therefore all methods and fields available for BiObject are also available for BiKeystroke .

Constructor

new BiKeystroke ( nModifiers,nKeyCode )

Parameters

NameTypeOptionalDefaultDescription
nModifiersNumberFlags for the modifiers that are held down (e.g. CTRL + ALT + SHIFT). One of the BiKeystroke.MODIFIER_FLAGS values.
nKeyCodeNumberThe key-code/char-code of the pressed key (e.g. S == 83, F4 == 115).

Properties

NameTypegetsetDescription
keyCodeNumbercheckedThe key code (char-code) of the pressed (released) key.
modifiersNumbercheckedThe modifier keys (flags) in this keystroke

Methods

NameDescription
matchesChecks if this keystroke is the same as another.
matchesBundleShortcutChecks if this keystroke matches a shortcut in the current bundle.
matchesShortcutChecks if this keystroke matches a shortcut.
matchesStringChecks if this keystroke is the same as another. Parses the string before checking.
toStringOverrides Object.toString()

Events

None.

Static Methods

NameDescription
fromStringParse a keystroke from a string. Format should be similar to "ctrl+shift+s". Separators can be plus (+) or minus (-). Mixing is allowed. Any one of the BiKeystroke.MODIFIER_FLAGS may be used. Case is ignored. The last value must always be the pressed key. If the parsing fails an error is thrown. Mac-style shortcuts (e.g. "⇧⌥⌃⌘F4") are also allowed (even if they may be hard to type).
modifiersFromStringParse keystroke modifiers from a string. Format should be similar to "ctrl+shift". Separators can be plus (+) or minus (-). Mixing is allowed. Any one of the BiKeystroke.MODIFIER_FLAGS may be used. Case is ignored. The last value must always be the pressed key. If the parsing fails an error is thrown. Mac-style modifiers (e.g. "⇧⌥⌃⌘") are also allowed (even if they may be hard to type).
modifiersMatchBundleChecks whether a set of modifiers matches a specific set in the bundle.

Static Fields

NameTypeDescription
MODIFIER_FLAGSNumberAll available modifier flags. SHIFT, ALT/OPTION, CTRL/CONTROL, META/COMMAND

Enumerations

None.

Remarks

None.

Method Details

matches

Checks if this keystroke is the same as another.

Syntax

object.matches ( oKeystroke )

Parameters

NameTypeOptionalDefaultDescription
oKeystrokeBiKeystrokeThe other keystroke.

Return Type

Boolean

matchesBundleShortcut

Checks if this keystroke matches a shortcut in the current bundle.

Syntax

object.matchesBundleShortcut ( sName [ ,bIgnoreZero [ ,bRtl ] ] )

Parameters

NameTypeOptionalDefaultDescription
sNameStringThe bundle name of the shortcut
bIgnoreZeroBooleancheckedfalse Whether the shortcut unset modifiers should be ignored.
bRtlBooleancheckedfalse Whether right/left keys should be switched.

Return Type

Boolean

matchesShortcut

Checks if this keystroke matches a shortcut.

Syntax

object.matchesShortcut ( oKeystroke [ ,bIgnoreZero [ ,bRtl ] ] )

Parameters

NameTypeOptionalDefaultDescription
oKeystrokeBiKeystrokeThe shortcut keystroke.
bIgnoreZeroBooleancheckedfalse Whether the shortcut unset modifiers should be ignored.
bRtlBooleancheckedfalse Whether right/left keys should be switched.

Return Type

Boolean

matchesString

Checks if this keystroke is the same as another. Parses the string before checking.

Syntax

object.matchesString ( s )

Parameters

NameTypeOptionalDefaultDescription
sStringThe string representation of the keystroke

Return Type

Boolean

toString

Overrides Object.toString()

Syntax

object.toString ( bKeypress )

Parameters

NameTypeOptionalDefaultDescription
bKeypressBooleanfalse Optional parameter that hints that this is from a keypress event

Return Type

String

Static Method Details

fromString

Parse a keystroke from a string. Format should be similar to "ctrl+shift+s". Separators can be plus (+) or minus (-). Mixing is allowed. Any one of the BiKeystroke.MODIFIER_FLAGS may be used. Case is ignored. The last value must always be the pressed key. If the parsing fails an error is thrown. Mac-style shortcuts (e.g. "⇧⌥⌃⌘F4") are also allowed (even if they may be hard to type).

Syntax

BiKeystroke . fromString ( s )

Parameters

NameTypeOptionalDefaultDescription
sStringThe string to parse.

Return Type

BiKeystroke

modifiersFromString

Parse keystroke modifiers from a string. Format should be similar to "ctrl+shift". Separators can be plus (+) or minus (-). Mixing is allowed. Any one of the BiKeystroke.MODIFIER_FLAGS may be used. Case is ignored. The last value must always be the pressed key. If the parsing fails an error is thrown. Mac-style modifiers (e.g. "⇧⌥⌃⌘") are also allowed (even if they may be hard to type).

Syntax

BiKeystroke . modifiersFromString ( s )

Parameters

NameTypeOptionalDefaultDescription
sStringThe string to parse.

Return Type

Number

modifiersMatchBundle

Checks whether a set of modifiers matches a specific set in the bundle.

Syntax

BiKeystroke . modifiersMatchBundle ( sName,nModifiers [ ,bIgnoreZero ] )

Parameters

NameTypeOptionalDefaultDescription
sNameStringthe name of the set (or sets) of modifiers in the bundle
nModifiersNumbera sum of numbers from the MODIFIER_FLAGS enumeration
bIgnoreZeroBooleancheckedfalse Whether the shortcut unset modifiers should be ignored.

Return Type

Boolean