class_docstr: :param key: A `Keys` instance or text (one character).
  :param data: The received string on stdin. (Often vt100 escape codes.)
class_docstr_tok: [":","param","key",":","A","`","Keys","`","instance","or","text","(","one","character",")",".",":","param","data",":","The","received","string","on","stdin",".","(","Often","vt100","escape","codes",".",")"]
code: def __init__(self, key, data=None):
      assert isinstance(key, (six.text_type, Key))
      assert data is None or isinstance(data, six.text_type)
  
      if data is None:
          data = key.name if isinstance(key, Key) else key
  
      self.key = key
      self.data = data
  
imports: from __future__ import unicode_literals
  from prompt_toolkit.buffer import EditReadOnlyBuffer
  from prompt_toolkit.filters.cli import ViNavigationMode
  from prompt_toolkit.keys import Keys, Key
  from prompt_toolkit.utils import Event
  from .registry import BaseRegistry
  from collections import deque
  from six.moves import range
  import weakref
  import six
label_desc: Use image node_id 1 to create a new KeyPress object from inherited base classes: object with example: obj = KeyPress(key, data)