This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. Extensions can be found in the GoJS kit under the `extensions` or `extensionsTS` folders. See the Extensions intro page for more information.

### Hierarchy

- Robot

A class for simulating mouse and keyboard input.

As a special hack, this supports limited simulation of drag-and-drop between Diagrams, by setting both the `sourceDiagram` and `targetDiagram` properties on the `eventprops` argument of the mouseDown/mouseMove/mouseUp methods. Although InputEvent.targetDiagram is a real property, the `sourceDiagram` property is only used by these Robot methods.

If you want to experiment with this extension, try the Simulating Input sample.

## Index

### Constructors

- constructor

### Properties

- diagram

### Methods

- keyDown
- keyUp
- mouseDown
- mouseMove
- mouseUp
- mouseWheel

## Constructors

### constructor

- new Robot(dia?: Diagram): Robot

- Construct a robot for a given Diagram. If none is provided, a new Diagram will be created.

  #### Parameters

  - ##### Optional dia: Diagram

  #### Returns Robot

## Properties

### diagram : Diagram

- Gets or sets the Diagram associated with this Robot.

## Methods

### keyDown

- keyDown(keyorcode: string | number, time?: number, eventprops?: ObjectData): void

- Simulate a key down event.

  #### Parameters

  - ##### keyorcode: string | number

  - ##### Optional time: number

    the timestamp of the simulated event, in milliseconds; default zero

  - ##### Optional eventprops: ObjectData

    an optional argument providing properties for the InputEvent.

  #### Returns void

### keyUp

- keyUp(keyorcode: string | number, time?: number, eventprops?: ObjectData): void

- Simulate a key up event.

  #### Parameters

  - ##### keyorcode: string | number

  - ##### Optional time: number

    the timestamp of the simulated event, in milliseconds; default zero

  - ##### Optional eventprops: ObjectData

    an optional argument providing properties for the InputEvent.

  #### Returns void

### mouseDown

- mouseDown(x: number, y: number, time?: number, eventprops?: ObjectData): void

- Simulate a mouse down event.

  #### Parameters

  - ##### x: number

    the X-coordinate of the mouse point in document coordinates.

  - ##### y: number

    the Y-coordinate of the mouse point in document coordinates.

  - ##### Optional time: number

    the timestamp of the simulated event, in milliseconds; default zero

  - ##### Optional eventprops: ObjectData

    an optional argument providing properties for the InputEvent.

  #### Returns void

### mouseMove

- mouseMove(x: number, y: number, time?: number, eventprops?: ObjectData): void

- Simulate a mouse move event.

  #### Parameters

  - ##### x: number

    the X-coordinate of the mouse point in document coordinates.

  - ##### y: number

    the Y-coordinate of the mouse point in document coordinates.

  - ##### Optional time: number

    the timestamp of the simulated event, in milliseconds; default zero

  - ##### Optional eventprops: ObjectData

    an optional argument providing properties for the InputEvent.

  #### Returns void

### mouseUp

- mouseUp(x: number, y: number, time?: number, eventprops?: ObjectData): void

- Simulate a mouse up event.

  #### Parameters

  - ##### x: number

    the X-coordinate of the mouse point in document coordinates.

  - ##### y: number

    the Y-coordinate of the mouse point in document coordinates.

  - ##### Optional time: number

    the timestamp of the simulated event, in milliseconds; default zero

  - ##### Optional eventprops: ObjectData

    an optional argument providing properties for the InputEvent.

  #### Returns void

### mouseWheel

- mouseWheel(delta: number, time?: number, eventprops?: ObjectData): void

- Simulate a mouse wheel event.

  #### Parameters

  - ##### delta: number

    non-zero turn

  - ##### Optional time: number

    the timestamp of the simulated event, in milliseconds; default zero

  - ##### Optional eventprops: ObjectData

    an optional argument providing properties for the InputEvent.

  #### Returns void

Copyright © 1998-2019 by Northwoods Software Corporation.