From: Gabriel Horner Date: 2011-09-11T02:12:37+09:00 Subject: Re: Ruby Readline - do something when a key combination is pressed Marc Heiler wrote in post #1020870: > Hi, > > When I use readline, I would like to run an action if a key combination > is pressed. > > Alt + cursor key left > > Alt + cursor key right > > In other words, I want the cursor key to do something, but only when it > is pressed in combination. > > If this is not possible in Readline, perhaps someone knows how else to > fetch user input, including ALL possible key combination? > > But, the problem also is ... I do NOT want to press ENTER. > > The user should just be able to press: > > alt + cursor_key_left > > And this should trigger something. > > Is that even possible at all? It's possible but it's not clear if you're talking about invoking it in irb or a unix shell. If in irb, you can invoke a ruby method as you'd like if you put this in ~/.inputrc: $if Ruby "\C-x\C-p": "toggle_object_complete\n" $endif -- Posted via http://www.ruby-forum.com/.