Quoted
Does this do what you want?
print "What is your name "
name = readline
print "Hello, #{name}\n"
Or are you wanting to wait for a single keystroke? If so, what OS are
you using? AFAIK, there is no good operating system independent way to
do this, but there are good ways for any given OS.
-- Markus
On Sun, 2004-09-05 at 20:35, Phanixis wrote:
> I am new to Ruby an have what should be a simple problem. I want to create
> code that first accepts a user input from the keyboard, and then continues
> to execute code. I am capable of writing a method that registers input
> from a keyboard a stores them within variables for my needs. However,
> this methods executes so fast that unless a key was being pressed at the
> time it was called, it is impossible for the user the press the key in
> time.
>
> Currently, my only need is to collect an input from the keyboard, I am not
> interested in running any other methods concurrently while listening for
> user input. I just want to program to wait, and not act in any way, until
> an input from the keyboard is received.
>
> As a side note, is there anything similar to the Java "listeners" that I
> can use in Ruby.
>
> Thanks for your help.
>
This post has been edited 1 times, last edit by "Invest0r" (Mar 9th 2007, 11:44am)
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 |
def windowclose
loop do
Graphics.update
Input.update
if Input.trigger?(Input::C)
@levelup_window.visible = false
break
end
end
end
|

Forum Software: Burning Board® 3.1.6, developed by WoltLab® GmbH