• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Typing numbers to jump to items in a list

quattj

Member
I have a list of 128 items. I have scrolling with up, down, pgup, pgdn, home, and end. I'd also like to be able to jump to a specific number by typing it. I thought of using keyboard_string and reading the last 3 values, but that would also take letters and overly complicate processing.

Is there a fairly simple technique to use to do this sort of thing? I'm thinking of setting a timer for key inputs that starts when a number is pressed, and if another (number) key hasn't been pressed within the timer, jump to that number and reset the "typed number". I usually do keyboard input using the individual keyboard events, but that would be a disaster in this case, and I can't figure out the best way to handle it using the keyboard_* functions.
 

NightFrost

Member
You can use string_digits to filter everything but numbers from a string. And its probably better to use keyboard_lastchar to track just the last key pressed. You read it, handle the content if it wasn't empty, and then clear it. It also might be a good idea to create some sort of visible input field functionality so user isn't typing numbers blind. Click on it and it clears keyboard_lastchar and starts watching its content. If a number is found, it is appended to input string. Pressing enter or clicking outside the input field stops its action.
 

quattj

Member
Ahh, thanks. I was not aware of string_digits. I'll give that a shot with keyboard_lastchar.
 
Top