from gi.repository import Gtk

class Window(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self)

        view = Gtk.TextView()
        view.connect('key-press-event', self.on_key_press_event)
        self.add(view)

        self.show_all()

    def on_key_press_event(self, widget, event):
    	self.event(event)

window = Window()
Gtk.main()
