Hi List<br>I am trying to figure out a way to hack keyboard input and finally I&#39;ve found a similar thing in py_gtk. The method is given below.-<br>_________________________________<br>def on_TextView_key_press(self, widget,event):<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; keycode = event.hardware_keycode<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; self.undo_manager.cur_keyval = event.keyval<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # Skip if Ctrl or Alt are pressed<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (&#39;GDK_CONTROL_MASK&#39; in event.state.value_names) \<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; or (&#39;GDK_MOD1_MASK&#39; in event.state.value_names):<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return False<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (not self.IsLangDefault):<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; try:<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # get char from the mapping<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (&#39;GDK_SHIFT_MASK&#39; in event.state.value_names) or \<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (&#39;GDK_LOCK_MASK&#39; in event.state.value_names):<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; new_char = self.LayManager.dict_trans[keycode][1]<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else:<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; new_char = self.LayManager.dict_trans[keycode][0]<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; self.textbuffer.delete_selection(True, self.textview.get_editable())<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; self.textbuffer.insert_interactive_at_cursor(new_char, self.textview.get_editable())<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; except : <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # return unchanged keyval for unrecognized keystrokes<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return False<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # insert the new char instead<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return True<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else:<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return False<br>_______________________________________________<br>Exactly the same thing I am trying to do in c# with gtk. So I am exprerimenting to get values of keys in another widget.<br>
I only want to ask why I am unable to catch keypress events raised by normal keys (a, b, c, d, y, 1, 2 etc etc). Modifier keys when pressed raise the event and I get the output as well. You can see the code how I am doing this.<br>
protected virtual void OnTextview1KeyPressEvent (object o, Gtk.KeyPressEventArgs args)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; char key = (char)args.Event.Key;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; entry1.Text = key.ToString();<br>&nbsp;&nbsp;&nbsp; }<br>There are only two widgets on window. The keypress event is raised in textview1 and its output is in entry1. I am getting output (basically strange characters) when I press shift, alt, ctrl or caps lock or num lock but normal keys are not raising events. Where I am wrong plz point out so I can correct the code??<br>
OR IT IS A BUG IN GTK#??????<br>Regards<br><br>-- <br>Muhammad Shakir Aziz محمد شاکر عزیز<br>