Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: Keyboard modifier (Not hold the CTRL and the SHIFT)

  1. #1
    Junior Member
    Join Date
    Mar 2020
    Posts
    17

    Keyboard modifier (Not hold the CTRL and the SHIFT)

    I will send a "CTRL + SHIFT 15" from the Teensy 3.6 with the normal USB connection, it wil not be press and hold the "CTRL + SHIFT".
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    The Code:
    Keyboard.set_modifier(MODIFIERKEY_CTRL | MODIFIERKEY_SHIFT);
    Keyboard.set_key1(KEY_1);
    Keyboard.set_key2(KEY_5);
    Keyboard.send_now();
    delay(20);
    Keyboard.set_modifier(0);
    Keyboard.set_key1(0);
    Keyboard.set_key2(0);
    Keyboard.send_now();

    When i send this from a normal keyboard, i see this:
    ---------------------------------------------------------------------
    SHIFT CTRL 49 1
    SHIFT CTRL 53 5
    CTRL 16 
    17 

    When i send this from the Teensy, i see this:
    ------------------------------------------------------------
    SHIFT 17 
    16 
    49 1
    53 5


    What are wrong?

    Thanks.
    Last edited by stanleyvc1; 07-28-2020 at 10:01 AM.

  2. #2
    Junior Member
    Join Date
    Mar 2020
    Posts
    17
    This will work:

    Keyboard.press(MODIFIERKEY_CTRL);
    delay(2);
    Keyboard.press(MODIFIERKEY_SHIFT);
    delay(2);
    Keyboard.press(KEY_1);
    delay(2);
    Keyboard.release(KEY_1);
    delay(2);
    Keyboard.press(KEY_6);
    delay(2);
    Keyboard.release(KEY_6);
    delay(2);
    Keyboard.release(MODIFIERKEY_SHIFT);
    delay(2);
    Keyboard.release(MODIFIERKEY_CTRL);

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •