Skip to main content

KeyPressEvent

Class

This event is triggered when the user presses a key.

  • Available on all platforms
Platform details: Snapchat, SPECS, Camera Kit Web, Camera Kit Mobile fully supported.

Platform details

  • Snapchat — Fully supported.

  • SPECS — Fully supported.

  • Camera Kit Web — Fully supported.

  • Camera Kit Mobile — Fully supported.

Index

Example

function onKeyPress(eventData)
{
var key = eventData.key;
}

var event = script.createEvent("KeyPressEvent");
event.bind(onKeyPress);

Extends

Properties

enabled

enabled: boolean

If true, the event is able to trigger. If false, the event will not trigger.

Default Value

true

Inherited from

SceneObjectEvent.enabled


key

readonly key: Keys

Returns the key code of the pressed key.


modifiers

readonly modifiers: KeyModifiers[]

Returns the modifier keys active when the key was pressed as a set of enums.

Methods

bind()

bind(evCallback): void

Binds a callback function to this event.

Parameters

ParameterType
evCallback(arg1) => void

Returns

void

Inherited from

SceneObjectEvent.bind


getSceneObject()

getSceneObject(): SceneObject

Returns the SceneObject this Event is associated with.

Returns

SceneObject

Inherited from

SceneObjectEvent.getSceneObject


getTypeName()

static getTypeName(): TypeName<KeyPressEvent>

Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

Returns

TypeName<KeyPressEvent>

Overrides

SceneObjectEvent.getTypeName


getTypeName()

getTypeName(): string

Returns the typename of the SceneEvent.

Returns

string

Inherited from

SceneObjectEvent.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

SceneObjectEvent.isOfType


isSame()

isSame(other): boolean

Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

SceneObjectEvent.isSame