title: How to freeze use of key tab in tkinter python
body: <p>I am trying to make a simple application that scrambles keyboard letters while typing. I am using python along with tkinter. I have a text widget and i need to disable the key tab in my application. I tried it using following code.</p>
  
  <pre><code>text.bind("&lt;Tab&gt;", no_op)
  </code></pre>
  
  <p>Here no_op is the function given below:</p>
  
  <pre><code>def no_op(self):
      return "break"        
  </code></pre>
  
  <p>But I am not getting the expected result. I am posting the whole code below.</p>
  
  <pre><code>import Tkinter as tk
  
  def onKeyPress(event):
      first=event.char
      second=ord(first)
      if second==32:
          second=chr(second)
          text.insert('end', '%s' % (second ))
      elif second==8:
          length = len(text.get(1.0, 'end'))
          contents = text.get(1.0, 'end')
          newcon = contents[:-2]
          #text.insert('end', '%s' % (length ))
          text.delete(1.0,'end')
          text.insert('end', '%s' % (newcon ))
      elif(second&gt;=65 and second&lt;=90 or second&gt;=97 and second&lt;=122):
          second=chr(second+3)
          text.insert('end', '%s' % (second ))
  
  
  def no_op(self):
      return "break"
  
  
  root = tk.Tk()
  root.config(cursor='none')
  #root.attributes('-zoomed',True)
  text = tk.Text(root, background='white', foreground='black', font=('Comic Sans MS', 12))
  text.pack(expand=True,)
  
  text.bind("&lt;Tab&gt;", no_op)
  text.bind("&lt;Button-1&gt;", no_op)
  text.config(cursor="none")
  root.bind('&lt;KeyPress&gt;', onKeyPress)
  root.mainloop()
  </code></pre>
  
  <p>(<strong>Note</strong>: The problem is that when tab is pressed when some other widget has focus, the text cursor comes in the text area. Then, if I press any letter say,'a' both 'a' and 'd' is inserted to text field. I want to fix that.)</p>