### Navigation

- index
- modules |
- next |
- previous |
- Gate One Documentation »
- Gate One Applications »
- Terminal »
- Terminal Developer Documentation »

# terminal_input.js

Gate One's bundled Terminal application JavaScript (Input module) (source).

`GateOne.Terminal.``Input`

  Terminal-specific keyboard and mouse input stuff.

  `GateOne.Terminal.Input.``init`()

    Creates `GateOne.Terminal.Input.inputNode` to capture keys/IME composition and attaches appropriate events.

  `GateOne.Terminal.Input.``sendChars`()

    pop()s out the current `charBuffer` and sends it to the server.

  `GateOne.Terminal.Input.``onMouseWheel`(e)

    Attached to the mousewheel event on the Terminal application container; calls `preventDefault()` if "mouse motion" event tracking mode is enabled and instead sends equivalent xterm escape sequences to the server to emulate mouse scroll events.

    If the `Alt` key is held the user will be able to scroll normally.

  `GateOne.Terminal.Input.``onMouseMove`(e)

    Attached to the `contextmenu` event on the Terminal application container; calls `preventDefault()` if "mouse motion" event tracking mode is enabled to prevent the usual context menu from popping up.

    If the `Alt` key is held while right-clicking the normal context menu will appear.

  `GateOne.Terminal.Input.``onMouseMove`(e)

    Attached to the `mousemove` event on the Terminal application container when mouse event tracking is enabled; pre-sets `GateOne.Terminal.mouseUpEscSeq` with the current mouse coordinates.

  `GateOne.Terminal.Input.``onMouseDown`(e)

    Attached to the `mousedown` event on the Terminal application container; performs the following actions based on which mouse button was used:

    > - Left-click: Hides the pastearea.
    > - Right-click: If no text is highlighted in the terminal, makes sure the pastearea is visible and has focus.
    > - Middle-click: Makes sure the pastearea is visible and has focus so that middle-click-to-paste events (X11) will work properly. Alternatively, if there is highlighted text in the terminal a paste event will be emulated (regardless of platform).

  `GateOne.Terminal.Input.``onMouseUp`(e)

    Attached to the `mouseup` event on the Terminal application container; prevents the pastearea from being shown if text is highlighted in the terminal (so users can right-click to copy). Also prevents the pastearea from being instantly re-enabled when clicking in order to allow double-click events to pass through to the terminal (to highlight words).

    The last thing this function does every time it is called is to change focus to `GateOne.Terminal.Input.inputNode`.

  `GateOne.Terminal.Input.``onCopy`()

    Returns all 'pastearea' elements to a visible state after a copy operation so that the browser's regular context menu will be usable again (for pasting). Also displays a message to the user letting them know that the text was copied successfully (because having your highlighted text suddenly disappear isn't that intuitive).

  `GateOne.Terminal.Input.``capture`()

    Sets focus on the terminal and attaches all the relevant events (mousedown, mouseup, keydown, etc).

  `GateOne.Terminal.Input.``disableCapture`(e[, force])

    Disables the various input events that capture mouse and keystroke events. This allows things like input elements and forms to work properly (so keystrokes can pass through without intervention).

  `GateOne.Terminal.Input.``onPaste`(e)

    Attached to the 'paste' event on the terminal application container; converts pasted text to plaintext and sends it to the selected terminal.

  `GateOne.Terminal.Input.``queue`(text)

    Adds 'text' to the `GateOne.Terminal.Input.charBuffer` Array (to be sent to the server when ready via `GateOne.Terminal.sendChars()`).

  `GateOne.Terminal.Input.``queue`(cars)

    Prepends the ESC key string (`String.fromCharCode(27)`) to special character sequences (e.g. PgUp, PgDown, Arrow keys, etc) before adding them to the charBuffer

  `GateOne.Terminal.Input.``onCompositionStart`(e)

    Called when we encounter the `compositionstart` event which indicates the use of an IME. That would most commonly be a mobile phone software keyboard or foreign language input methods (e.g. Anthy for Japanese, Chinese, etc).

    Ensures that `GateOne.Terminal.Input.inputNode` is visible and as close to the cursor position as possible.

  `GateOne.Terminal.Input.``onCompositionEnd`(e)

    Called when we encounter the `compositionend` event which indicates the IME has completed a composition. Sends what was composed to the server and ensures that `GateOne.Terminal.Input.inputNode` is emptied & hidden.

  `GateOne.Terminal.Input.``onCompositionUpdate`(e)

    Called when we encounter the 'compositionupdate' event which indicates incoming characters; sets `GateOne.Terminal.Input.composition`.

  `GateOne.Terminal.Input.``onKeyUp`(e)

    Called when the terminal encounters a `keyup` event; just ensures that `GateOne.Terminal.Input.inputNode` is emptied so we don't accidentally send characters we shouldn't.

  `GateOne.Terminal.Input.``onInput`(e)

    Attached to the `input` event on `GateOne.Terminal.Input.inputNode`; sends its contents. If the user is in the middle of composing text via an IME it will wait until their composition is complete before sending the characters.

  `GateOne.Terminal.Input.``onKeyDown`(e)

    Handles keystroke events by determining which kind of event occurred and how/whether it should be sent to the server as specific characters or escape sequences.

  `GateOne.Terminal.Input.``execKeystroke`(e)

    For the Terminal application, executes the keystroke or shortcut associated with the given keydown event (e).

  `GateOne.Terminal.Input.``emulateKey`(e, skipF11check)

    This method handles all regular keys registered via onkeydown events (not onkeypress) If skipF11check is true, the F11 (fullscreen check) logic will be skipped.

    Note

    `Shift+key` also winds up being handled by this function.

  `GateOne.Terminal.Input.``emulateKeyCombo`(e)

    This method translates ctrl/alt/meta key combos such as `Ctrl-c` into their string equivalents using `GateOne.Terminal.Input.keyTable` and sends them to the server.

### Navigation

- index
- modules |
- next |
- previous |
- Gate One Documentation »
- Gate One Applications »
- Terminal »
- Terminal Developer Documentation »