How to send key events to the webkit.WebView () control?

advertisements

I created mini browser for touch panels. I used Python, GTK and WebKit. I want to create touch keyboard built-in that browser. How to send key events to webkit.WebView() control?

My code:

#!/usr/bin/python
import webkit, gtk
window = gtk.Window()
browser = webkit.WebView()
window.add(browser)
window.show()
browser.show()
browser.load_uri("http://google.com")
window.fullscreen()
window.connect("delete-event", gtk.main_quit)
window.set_title("Dashboard")
gtk.main()

Sorry for my bad English...


You can do it like this:

event = gtk.gdk.Event(gtk.gdk.KEY_PRESS)
event.keyval = gtk.keysyms.Return
event.time = 0
browser.emit('key-press-event', event)

for example, to send an Enter key press.