Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

keyboard module..?

Riku

Member

hey guys.
I searched for a keyboard module and found two but without a guide how to use. I need a keyboard module that can check if a key is pressed holded and released...
i hope there exist one...
plz help me^^
 
You should be able to do that with any kind of input script...

Code:
if Input.trigger?(Input::Key) # checks for one-time key activation
  # stuff
end

if Input.press?(Input::Key) # checks if the key is pressed (for an unlimited amount of time)
  # stuff
  @temp_trigger = true
else
  if @temp_trigger == true # if the key has been released
    # stuff
    @temp_trigger = false
  else # if the trigger hasn't been pressed after this if statement has been executed
    # stuff
  end
end
 

Riku

Member

i mean can you make a event with a condition fork where this is checked?
not in the scripteditor
if it is possible pls let me know how and which script I need^^

it would be very nice
 
Well, you need to replace Key with the key you desire... C, B, A, R, L, ... or custom keys you have in your input script, but the ones I posted should work with or without. Note that those keys aren't what they're called, they're just placeholders; C is for Enter and Space, for example... you can assign those with F1 while running your game.
 

Riku

Member

ah I figured it out^^
I have to put in the script box one of the following...
if Input.get_function == "function"
if Input.get_letters== "letter"
if Input.get_numbers == "number"
if Input.get_key == "char"
if Input.get_direction== "number" # Number Pad

It works if I check the number "1" on the keyboard but letters don't work completly.
I want to check A W D
it doesnt work...

maybe the letter is used in the standard inputs ...?

EDIT: wait maybe the key doesn't exist in the module ...
here check it pls^^
http://www.dubealex.com/asylum/index.php?showtopic=2557
 

Riku

Member

okay now it works thx!^^

next problem... how do I check now letter"A"
like you said in your first post?

EDIT: i figured out i have to put in Input.pressed(Input::Letters["A"]
ok now the last question^^
how do I check if the key is pressed all the time and when he is released
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top