[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Get key pressed

Alejandro Michelin salomon

2/27/2009 7:03:00 PM

Hi
i need to now how to get a key pressed.

I have a tcpserver, and i want to get if the user press control + x.
If the users press control + x i make the shutdown.

Can you give my some ligth?
--
Posted via http://www.ruby-....

7 Answers

Tom Cloyd

2/28/2009 4:40:00 AM

0

Alejandro Michelin salomon wrote:
> Hi
> i need to now how to get a key pressed.
>
> I have a tcpserver, and i want to get if the user press control + x.
> If the users press control + x i make the shutdown.
>
> Can you give my some ligth?
>
I have an interest in this myself, and hope soon to be acting on it.
Meanwhile, MY prime resource is this:

On page 776 of the <Ruby Cookbook> (see "Resources" below) takes up
"Getting Input One Character at a Time". It discusses the Curses
extension that is a part of Ruby, and the Highline library (a gem). It's
only a couple of pages, but its the most focused discussion I've seen
yet. I assume that I'll learn more from the RDoc material associated
with the Highline gem, and probably in various blogs out there
somewhere, etc.

All I know... hope it helps.

t.

Resources:

* O'Reilly publisher sales page:
http://oreilly.com/catalog/9780... - Prices here seem high. I
know I didn't pay $40 for my PDF version. Amazon may have used copies
for cheaper.

--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< tc@tomcloyd.com >> (email)
<< TomCloyd.com >> (website)
<< sleightmind.wordpress.com >> (mental health weblog)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


James Gray

2/28/2009 2:38:00 PM

0

On Feb 27, 2009, at 10:40 PM, Tom Cloyd wrote:

> On page 776 of the <Ruby Cookbook> (see "Resources" below) takes up
> "Getting Input One Character at a Time". It discusses the Curses
> extension that is a part of Ruby, and the Highline library (a gem).
> It's only a couple of pages, but its the most focused discussion
> I've seen yet. I assume that I'll learn more from the RDoc material
> associated with the Highline gem, and probably in various blogs out
> there somewhere, etc.

Here's a blog post you might enjoy, though it won't help with the
TCPServer case being discussed in this thread:

http://blog.grayproductions.net/articles/i_just_want_one...

James Edward Gray II

Tom Cloyd

2/28/2009 7:21:00 PM

0

James Gray wrote:
> On Feb 27, 2009, at 10:40 PM, Tom Cloyd wrote:
>
>> On page 776 of the <Ruby Cookbook> (see "Resources" below) takes up
>> "Getting Input One Character at a Time". It discusses the Curses
>> extension that is a part of Ruby, and the Highline library (a gem).
>> It's only a couple of pages, but its the most focused discussion I've
>> seen yet. I assume that I'll learn more from the RDoc material
>> associated with the Highline gem, and probably in various blogs out
>> there somewhere, etc.
>
> Here's a blog post you might enjoy, though it won't help with the
> TCPServer case being discussed in this thread:
>
> http://blog.grayproductions.net/articles/i_just_want_one...
>
> James Edward Gray II
>
>
James, THANKS! That pretty much nails it. A fine contribution to the
community. (Nice clean minimalist blog layout too...) ~t.

--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< tc@tomcloyd.com >> (email)
<< TomCloyd.com >> (website)
<< sleightmind.wordpress.com >> (mental health weblog)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Tim Greer

2/28/2009 7:34:00 PM

0

Alejandro Michelin salomon wrote:

> Hi
> i need to now how to get a key pressed.
>
> I have a tcpserver, and i want to get if the user press control + x.
> If the users press control + x i make the shutdown.
>
> Can you give my some ligth?

To be clear, is this a tcpserver running on the local system where you
want to catch the signal (CTRL-X) or do you mean the tcpserver is
running on a remote system and you want to capture the local singal and
send that to the remote service?
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!

Martin DeMello

2/28/2009 8:25:00 PM

0

On Sat, Feb 28, 2009 at 8:07 PM, James Gray <james@grayproductions.net> wrote:
>
> Here's a blog post you might enjoy, though it won't help with the TCPServer
> case being discussed in this thread:
>
> http://blog.grayproductions.net/articles/i_just_want_one...

Highline is an excellent example of a ruby library that takes a
single, hard problem and solves it really, really well.

martin

Alejandro Michelin salomon

2/28/2009 8:33:00 PM

0

Tim Greer wrote:
> Alejandro Michelin salomon wrote:
>
>> Hi
>> i need to now how to get a key pressed.
>>
>> I have a tcpserver, and i want to get if the user press control + x.
>> If the users press control + x i make the shutdown.
>>
>> Can you give my some ligth?
>
> To be clear, is this a tcpserver running on the local system where you
> want to catch the signal (CTRL-X) or do you mean the tcpserver is
> running on a remote system and you want to capture the local singal and
> send that to the remote service?

Tim i need to catch the signal ctrl-x on local machine, to shutdown the
server.

The problem is this code :

client = server.accept
The signal ctrl-x does nothing.

--
Posted via http://www.ruby-....

Tim Greer

2/28/2009 8:46:00 PM

0

Alejandro Michelin salomon wrote:

> Tim Greer wrote:
>> Alejandro Michelin salomon wrote:
>>
>>> Hi
>>> i need to now how to get a key pressed.
>>>
>>> I have a tcpserver, and i want to get if the user press control + x.
>>> If the users press control + x i make the shutdown.
>>>
>>> Can you give my some ligth?
>>
>> To be clear, is this a tcpserver running on the local system where
>> you want to catch the signal (CTRL-X) or do you mean the tcpserver is
>> running on a remote system and you want to capture the local singal
>> and send that to the remote service?
>
> Tim i need to catch the signal ctrl-x on local machine, to shutdown
> the server.
>
> The problem is this code :
>
> client = server.accept
> The signal ctrl-x does nothing.
>

Sorry if I wasn't clear, is the server local to the same machine where
you have the keyboard connected that will send the command? Will this
perhaps be on a remote (or local) server in shell/cli? That is, what
interface will you need to use to pass this signal to? (I hope that
makes sense).
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!