Problem Having Ruby Wait for a User Input

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.

Not sure what your problem is as you didn't paste sample code, but this
should work as you expect:

puts "Please enter something: "
a = gets.chomp
puts "You entered: #{a}"

As a side note, is there anything similar to the Java "listeners" that

I

can use in Ruby.

Listeners for what? There is a generic Observer/Observable pattern (see
http://www.ruby-doc.org/corelib/files/observer_rb.html\), and there are
some hooks into the system (e.g.
Class).
What are you trying to listen to?

Here is the code in question, it is intended to get only a single key press
for a limited range of keys.

def key_input #Get arbitrary keyboard input
    input = 0
    n = 0
    for i in 1..18
      if Input.trigger?(i)
        n = i
      end
    end
    if n > 0
      input = n
    end
   return input
  end

Does this clear anything up?

Thanks

Oh, your first link is broken.