# How to disable ctrl + c key in ruby on rails

**URL:** <https://www.ruby-forum.com/t/how-to-disable-ctrl-c-key-in-ruby-on-rails/144078>\
**Category:** Ruby\
**Created:** [July 25, 2008, 7:21am UTC](https://www.ruby-forum.com/t/how-to-disable-ctrl-c-key-in-ruby-on-rails/144078 "2008-07-25T07:21:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sujith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@sujith](https://www.ruby-forum.com/u/sujith)\
**Post date:** [July 25, 2008, 7:21am UTC](https://www.ruby-forum.com/t/how-to-disable-ctrl-c-key-in-ruby-on-rails/144078/1 "2008-07-25T07:21:14Z")

</div>

I am showing document in browser  
i want to disable the copy option ctrl + c key in ruby  
please help me out

---

<div class="post-metadata">

**Author:** ![sujith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@sujith](https://www.ruby-forum.com/u/sujith)\
**Post date:** [July 25, 2008, 7:23am UTC](https://www.ruby-forum.com/t/how-to-disable-ctrl-c-key-in-ruby-on-rails/144078/2 "2008-07-25T07:23:49Z")

</div>

Sujith Gangaraju wrote:

> I am showing document in browser  
> i want to disable the copy option ctrl + c key in ruby  
> please help me out

Might work to do it the traditional Ruby way:

[http://betterlogic.com/roger/?p=110](http://betterlogic.com/roger/?p=110)

windows:  
trap :INT, proc { â€˜ha got your ctrl-c!â€™ }

and linux

trap â€SIGUSR1â€³, proc {â€™got it in linux, tooâ€™}

I think. Maybe add to environment.rb?

---

<div class="post-metadata">

**Author:** ![sujith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@sujith](https://www.ruby-forum.com/u/sujith)\
**Post date:** [July 25, 2008, 10:35am UTC](https://www.ruby-forum.com/t/how-to-disable-ctrl-c-key-in-ruby-on-rails/144078/3 "2008-07-25T10:35:12Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

On Jul 25, 2008, at 7:19 AM, Roger P. wrote:

> trap :INT, proc { â€˜ha got your ctrl-c!â€™ }
> 
> and linux
> 
> trap â€SIGUSR1â€³, proc {â€™got it in linux, tooâ€™}
> 
> ## I think. Maybe add to environment.rb?
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

As I see it: he doesn’t want the user to copy text.

Not the answer you might expect: don’t even try. You showed him the  
text. If he is serious, he will use the old analog method of copying.

Regards,  
Florian G.  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.8 (Darwin)

iEYEARECAAYFAkiJkAEACgkQJA/zY0IIRZaWTwCdGtDS/hlMtDqQr9pfWevYGQ6s  
xQkAnitMod6+mKZ0IgYV0syJyPM3Uosc  
=/UlL  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![sujith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@sujith](https://www.ruby-forum.com/u/sujith)\
**Post date:** [July 25, 2008, 10:38am UTC](https://www.ruby-forum.com/t/how-to-disable-ctrl-c-key-in-ruby-on-rails/144078/4 "2008-07-25T10:38:10Z")

</div>

On 25 Jul 2008, at 06:19, Roger P. wrote:

> trap :INT, proc { â€˜ha got your ctrl-c!â€™ }
> 
> and linux
> 
> trap â€SIGUSR1â€³, proc {â€™got it in linux, tooâ€™}
> 
> I think. Maybe add to environment.rb?

That would stop the Rails application from processing a ctrl-c on the  
server keyboard (if it has one) but would make no difference in the  
browser as the Ruby code doesn’t run there.

Ellie

## Eleanor McHugh Games With Brains [http://slides.games-with-brains.net](http://slides.games-with-brains.net)

raise ArgumentError unless @reality.responds\_to? :reason
