Keyboard.KeyHit appears to have auto-repeat

About Monkey 2 Forums Monkey 2 Programming Help Keyboard.KeyHit appears to have auto-repeat

Tagged: 

This topic contains 7 replies, has 4 voices, and was last updated by  nerobot 2 years, 3 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #6288

    Ethernaut
    Participant

    Hi,

    It looks like Keyboard.KeyHit has auto-repeat, at least on MacOS. That’s probably fine for an app, but kind of a problem for games. Before I implement my own way around this, is there an easy to either turn this off or maybe increase the auto-repeat interval (setting it very high would also work well in a game).
    Thanks!

    #6292

    nerobot
    Participant

    What about using KeyReleased?

    #6293

    codifies
    Participant

    I always just check the state of keyDown …

    #6306

    Mark Sibly
    Keymaster

    It looks like Keyboard.KeyHit has auto-repeat, at least on MacOS.

    IMO, it shouldn’t and this MAY be a new thing.

    I’d like to fix this but am worried people are writing GUIs and depend on this behaviour – is this correct?

    Perhaps KeyHit (and KeyPressed!) could look like: KeyHit( key:Key,repat:Bool=False )

    #6308

    Ethernaut
    Participant

    Yes, KeyPressed ignoring auto-repeat and KeyHit using it ( or vice-versa, doesn’t matter to me) would be ideal! KeyHit seems to be undocumented, though. I only used it because I converted code from M1…

    Codifies, keydown is not really ideal for actions that should not repeat until the player hits the button again – for instance, Megaman or Super Mario style jumps.

    Thanks!

    #6309

    codifies
    Participant

    @ethernaut, no idea why really but I’ve often used a key released toggle for stuff like that…

    #6311

    Mark Sibly
    Keymaster

    I’ve added a ‘repeating:bool=False’ param to KeyPressed (and KeyHit) now in develop branch.

    #6313

    nerobot
    Participant

    About keyhit.

    As I know, keyhit usually return hits count since the beginning of main loop.

    Also, Hit = Press + Release. (or only pressed but don’t  increased until released)

    So if we are not releasing key it should return 1 (or true) at a loop frame key was pressed. And than will flushed at next frame and will return 0 or false until we release and press again.

    Upd. For gui apps we have OnKeyEvent() with full control of event, including its type that can be KeyRepeat.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.