pxt-microbit
pxt-microbit copied to clipboard
Pressing buttons too long returns nothing after release
Describe the bug When pressing button A, B or A+B for more than about 3 second, nothing happens. Carlos Pereira told me last week on Bett that might be due to a planned long press that never came into use.
A clear and concise description of what the bug is.
To Reproduce (makecode javascript:)
input.onButtonPressed(Button.A, function () { basic.showString("A") }) input.onButtonPressed(Button.B, function () { basic.showString("B") }) basic.clearScreen() basic.forever(function () {
})
Steps to reproduce the behavior: Press and hold button A for more than 3 seconds
Expected behavior Nothing happens even after releasing the button.
micro:bit version (please complete the following information): I believe it applies to all versions (I am using the V2 micro:bit and latest official makecode)
Additional context Say you have a microbit acting as a remote for a drone or hovercraft. You are instructed to press A + B to start the vehicle. Often people press and hold too long so they don´t get to start it. We have to tell them "To quickly press and release A+B" which is less practical.
It would be much better if the key press resulted in immediate action as soon as the key was pressed (not upon release), or at least upon release but no matter how long it was hold.
Or: Enabling long press for buttons A, B and A+B, which would give a lot more options.
Currently, there seems to be no option for a long press event (see screen shot)
This is a candidate for extension.
There is the button clicks extension https://makecode.microbit.org/pkg/bsiever/microbit-pxt-clicks
Or LONG_CLICK is 4 and HELD is 5 https://makecode.microbit.org/_bF2Xk7MmmazR
The list is here:-
https://github.com/lancaster-university/codal-core/blob/63f017fdcd12aca769264c36fe47e6071a40e502/inc/driver-models/AbstractButton.h#L35
https://github.com/lancaster-university/microbit-dal/blob/e5b67417d4dc6b01bc369d89bb1525fc7a9575c9/inc/drivers/MicroBitButton.h#L41
I think there are two different parts to this:
- We have a long press event and an extension to use it
- Because of the long press feature, when a user presses a button for too long the "normal" press event is not triggered.
We can leave the long press blocks as an extension, but 2) is probably a bug that needs consideration.
I agree completely, when there is no long press extension at play, you shouldn´t be held back for holding a bit too long. We have quite a lot of problems with it, especially the A+B, people are holding too long very often (when using micro:bit as a remote)