# ScrolledWindow - how to enable scrolling with page up and page down keys?

**URL:** <https://www.ruby-forum.com/t/scrolledwindow-how-to-enable-scrolling-with-page-up-and-page-down-keys/237993>\
**Category:** Ruby-Gnome 2\
**Created:** [December 10, 2013, 7:30pm UTC](https://www.ruby-forum.com/t/scrolledwindow-how-to-enable-scrolling-with-page-up-and-page-down-keys/237993 "2013-12-10T19:30:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [December 10, 2013, 7:30pm UTC](https://www.ruby-forum.com/t/scrolledwindow-how-to-enable-scrolling-with-page-up-and-page-down-keys/237993/1 "2013-12-10T19:30:00Z")

</div>

Hi,

I have a Scrolled Window. The mouse keys work fine, I can scroll up and  
down, but not with page up and page down.

Does someone understand why page up and page down does not work or more  
importantly how to enable this?

scrolled\_window = Gtk::ScrolledWindow.new  
scrolled\_window.add\_with\_viewport(text\_view)

When I am with my cursor inside such a scrolled window, the page up and  
page down keys don’t seem to make anything.

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [December 11, 2013, 8:30am UTC](https://www.ruby-forum.com/t/scrolledwindow-how-to-enable-scrolling-with-page-up-and-page-down-keys/237993/2 "2013-12-11T08:30:48Z")

</div>

You could try the key\_press event or button\_release\_event. Look in the  
docs. Add this line inside the method:

puts "Key number: " + key.to\_s

When the program runs, press the pageup key and look at the number.

Then write in your code:

if key == (number)  
`
end`

Hope this helps.

If you’re using visualruby, you could just add the method:

scrolledwindow1\_key\_press(me, key)  
if key.keyval == 65365 #PgUp

else if key.keyval == 65366 #PgDn

end  
end

Give that a shot.

Eric
