Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Press and hold down key #18

Open
gitolicious opened this issue Dec 17, 2022 · 2 comments
Open

Press and hold down key #18

gitolicious opened this issue Dec 17, 2022 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@gitolicious
Copy link

Describe the bug
How can I press and hold a key? For example I would like to hold down the space bar for five seconds. Would have expected this to work:

button:
  - platform: template
    name: "Hold Space"
    id: hold_space
    on_press:
      then:
      - ble_keyboard.press:
          id: myblekeyboard
          code: 0x20 # space
      - delay: 5000ms
      - ble_keyboard.release: myblekeyboard

It results in just the space bar being sent and immediately relesed. Did I misunderstand the press function in that it doesn't hold down the key until release is called? When would you use the release function otherwise?

Please complete the following information:

  • ESPHome version: 2022.11.5
  • Component version: latest? (how to find out? I simply put source: github://dmamontov/esphome-blekeyboard)
@gitolicious gitolicious added the bug Something isn't working label Dec 17, 2022
@dmamontov dmamontov added question Further information is requested and removed bug Something isn't working labels Dec 19, 2022
@dmamontov
Copy link
Owner

dmamontov commented Dec 19, 2022

@gitolicious In your case, a combination should help:

button:
  - platform: template
    name: "Hold Space"
    id: hold_space
    on_press:
      then:
      - ble_keyboard.combination:
         id: myblekeyboard
         delay: 5
         keys:
           - 0x20
           - 0x20

@gitolicious
Copy link
Author

I guess for that exact use case it would actually work - at least I can see a lot of space key events when putting 1000 instead of 5) I don't fully understand why this works with space (0x20) but not with "o" where two individual letters are being printed.
Unfortunately there are two extensions I would need for my actual use case:

  • I need to hold down Ctrl + Space (push to talk in MS Teams)
  • I don't know how long to hold down before releasing the keys (there is a physical button as input)
    Any ideas how to solve that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants