/ LJCJSCodeDoc / LJCCommonLib / LJC / IsShiftedKey


Parameters
key - The key value.
keyDownEvent - The keydown event.

Returns

true if the supplied key and shift key; otherwise false.

Syntax

JavaScript
static IsShiftedKey(key, keyDownEvent)

Checks keydown for a shift and the supplied key.

Example

JavaScript
<body>
  <input type="text" id="targetInput">
  <div id="testDiv"></div>
</body>

CompareValue = "";
      
// Checks keydown for a shift and the supplied key.
IsShiftKey()
{
  const elementID = "targetInput";
  const eventName = "keydown";
  const handler = this.IsShiftedKeyHandler.bind(this);
  LJC.AddEvent(elementID, eventName, handler);

  // Tab
  let eventOptions = {
    key: "Tab",
    code: "Tab",
    ctrlKey: false,
    shiftKey: true,
    altKey: false,
    metaKey: false,
    repeat: false,
    bubbles: true
  };
  let keyDownEvent = new KeyboardEvent(eventName, eventOptions);
  this.CompareValue = true;
  targetInput.dispatchEvent(keyDownEvent);

  let element = LJC.Element("targetInput");
  element.removeEventListener("keydown", handler);
}

IsShiftedKeyHandler(keyDownEvent)
{
  const result = LJC.IsShiftenKey("Tab", keyDownEvent);

  // result
  // this.CompareValue;
}

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.