All files / lib/event KeyEvent.ts

38.46% Statements 10/26
100% Branches 0/0
0% Functions 0/2
38.46% Lines 10/26

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87                              1x 1x                       1x 1x 1x   1x                                                                         1x                         1x 1x   1x  
/*
 * Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
 * http://paperjs.org/
 *
 * Copyright (c) 2011 - 2020, Jürg Lehni & Jonathan Puckey
 * http://juerglehni.com/ & https://puckey.studio/
 *
 * Distributed under the MIT license. See LICENSE file for details.
 *
 * All rights reserved.
 */
 
// TODO: remove eslint-disable comment and deal with errors over time
/* eslint-disable */
 
import { ref } from '~/globals';
import { Event } from './Event';
 
/**
 * @name KeyEvent
 *
 * @class The KeyEvent object is received by the {@link Tool}'s keyboard
 * handlers {@link Tool#onKeyDown}, {@link Tool#onKeyUp}. The KeyEvent object is
 * the only parameter passed to these functions and contains information about
 * the keyboard event.
 *
 * @extends Event
 */
export const KeyEvent = Event.extend(
  /** @lends KeyEvent# */ {
    _class: 'KeyEvent',
 
    initialize: function KeyEvent(type, event, key, character) {
      this.type = type;
      this.event = event;
      this.key = key;
      this.character = character;
    },
 
    /**
     * The type of mouse event.
     *
     * @name KeyEvent#type
     * @type String
     * @values 'keydown', 'keyup'
     */
 
    /**
     * The character representation of the key that caused this key event,
     * taking into account the current key-modifiers (e.g. shift, control,
     * caps-lock, etc.)
     *
     * @name KeyEvent#character
     * @type String
     */
 
    /**
     * The key that caused this key event, either as a lower-case character or
     * special key descriptor.
     *
     * @name KeyEvent#key
     * @type String
     * @values 'enter', 'space', 'shift', 'control', 'alt', 'meta', 'caps-lock',
     *     'left', 'up', 'right', 'down', 'escape', 'delete', ...
     */
 
    /**
     * @return {String} a string representation of the key event
     */
    toString: function () {
      return (
        "{ type: '" +
        this.type +
        "', key: '" +
        this.key +
        "', character: '" +
        this.character +
        "', modifiers: " +
        this.getModifiers() +
        ' }'
      );
    },
  }
);
 
ref.KeyEvent = KeyEvent;