Left Click activation

Im trying to use the when key is pressed block but it doesn’t include left Click is there a type script that could make that happen?

1 Like

In CoBlocks there is a left click block:

  • [when object is clicked]. The second one works on left mouse click.

For in TypeScript, you can use this code line: object.input.onClick(() => { … }
(The second scene of CoSpaces Edu :: 1. Basics TypeScript (speech/moveTo) has an example of a onClick line.)

I’m sorry, that i didn’t get your question right at first.
I guess you are looking for a Typescript code for events initiated other than by the left click. There are plenty of them: KeyCode type aliases

The code for an event initiated by right_mouse_click would look something like this:
** first define a function
function zdance () {
zebra.animation.playLooping(‘Dance’);
}
** then call it with a en event
Input.onKeyPressed(() =>{zdance()},“right_mouse_button”)

Some more examples: SLB-ZZH

1 Like