# Force enter in gets

**URL:** <https://www.ruby-forum.com/t/force-enter-in-gets/176093>\
**Category:** Ruby\
**Created:** [September 24, 2009, 6:35pm UTC](https://www.ruby-forum.com/t/force-enter-in-gets/176093 "2009-09-24T18:35:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbaty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3bc359/32.png) [@jbaty](https://www.ruby-forum.com/u/jbaty)\
**Post date:** [September 24, 2009, 6:35pm UTC](https://www.ruby-forum.com/t/force-enter-in-gets/176093/1 "2009-09-24T18:35:38Z")

</div>

Hi all,

Let’s say I have a ruby script that gets some user input:

name = gets

How can I make it so after 10 seconds of no input (or even if they start  
typing, it’ll cut them off after 10 seconds) it will continue? In other  
words, essentially simulate the return key after 10 seconds.

---

<div class="post-metadata">

**Author:** ![jbaty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3bc359/32.png) [@jbaty](https://www.ruby-forum.com/u/jbaty)\
**Post date:** [September 24, 2009, 9:10pm UTC](https://www.ruby-forum.com/t/force-enter-in-gets/176093/2 "2009-09-24T21:10:17Z")

</div>

Hi,

Am Freitag, 25. Sep 2009, 01:35:46 +0900 schrieb Jack B.:

> Let’s say I have a ruby script that gets some user input:
> 
> name = gets
> 
> How can I make it so after 10 seconds of no input (or even if they start  
> typing, it’ll cut them off after 10 seconds) it will continue? In other  
> words, essentially simulate the return key after 10 seconds.

name = if select [$stdin], nil, nil, 10 then gets else “Joe” end

Bertram
