Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    How to get around the key auto-repeat that kicks in after 1 sec

    Beginners
    clear
    2
    4
    447
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • spikey
      spikey F last edited by

      To be able to play a note by the USB-keyboard, I need to detect if a key is pressed and also how long. For this I use key = getKeyboardBuffer().

      showKeyboard()
      loop
          key = getKeyboardBuffer()
          print( key )
          update()
      repeat
      

      The problem is: if I press the a-key, it prints an "a", then stops for 1 s and then it continuously prints "a"'s. So, between "pressing the key" I don't know for the duration of 1 sec, if the key is still pressed or not.

      output, when pressing the a-key:

      a
      

      after one second

      aa
      

      and then the "a" gets continuously added every 1 ms

      aaaaaaaaaa->
      

      Does this mean its not possible to create a keyboard controlled piano, that is able to control the sound between ~1 ms and 1 s? Any suggestions are appreciated.

      1 Reply Last reply Reply Quote 0
      • pianofire
        pianofire Fuze Team last edited by

        @spikey I hadn't noticed that before. It looks like the keyboard has a built in "debounce" delay to stop unintentional auto repeat. There doesn't seem to be a way of changing or turning this off at the moment.

        1 Reply Last reply Reply Quote 0
        • spikey
          spikey F last edited by spikey

          Thank you for your comment. I was checking other keyboards, its either a default of the USB keyboards, or its from the switch OS, keyboard driver (I a guess, because on Windows I think one can adjust it). In the Switch-System-Settings, I could not found anything like this.
          I will try to use it how it is, it takes 29 frames, afterwards the key is repeated every 6 frames.


          I checked how this works in Korg Gadget (you can play sounds there using the USB keyboard as well). They seem to have found a way to do it. But understand me right, I did not write this as a bug report or change suggestion. Most probably nobody else will try to do anything with the key auto-repeat ever.😉

          1 Reply Last reply Reply Quote 1
          • spikey
            spikey F last edited by

            I found a workaround, not sure how solid it will be for the project behind:
            a) during the first 29 frames I process any character coming from the key buffer, I enter the status "KEY_PRESS" and "KEY_DOWN"
            b) after 30 frames I check if the key-character is in the buffer, so I keep the status "KEY_DOWN" if its not in the buffer we are in the state "KEY_RELEASED"
            c) after 30 frames I check every 7th frame if the character is in the key buffer and stay in "KEY_DOWN" status or if not change to "KEY_RELEASED"
            Example over here: https://fuzearena.com/forum/topic/947/re-use-sounds-from-the-soundfx-generator-with-the-usb-keyboard

            1 Reply Last reply Reply Quote 1
            • First post
              Last post