title: TypeError: 'undefined' is not a function (evaluating 'ime.registIMEKey()')
body: <p>Despite of setting and defining everything in Samsung smart TV SDK 4.0 I am getting this error:</p>
  
  <pre><code>TypeError: 'undefined' is not a function (evaluating 'ime.registIMEKey()')
  </code></pre>
  
  <p>Please help!</p>
  
  <pre><code>CODE:
  
  var widgetAPI = new Common.API.Widget();
  var tvKey = new Common.API.TVKeyValue();
  
  var wapal_magic =
  {
      elementIds: new Array(),
      inputs: new Array(),
      ready: new Array()
  };
  /////////////////////////
  var Input = function (id, previousId, nextId) {
      var previousElement = document.getElementById(previousId),
      nextElement = document.getElementById(nextId);
  
      var installFocusKeyCallbacks = function () {
      ime.setKeyFunc(tvKey.KEY_UP, function (keyCode) {
          previousElement.focus();
          return false;
      });
      ime.setKeyFunc(tvKey.KEY_DOWN, function (keyCode) {
          nextElement.focus();
          return false;
      });
      ime.setKeyFunc(tvKey.KEY_RETURN, function (keyCode) {
          widgetAPI.blockNavigation();
          return false;
      });
      ime.setKeyFunc(tvKey.KEY_EXIT, function (keyCode) {
          widgetAPI.blockNavigation();
          return false;
      });
  }
  
      var imeReady = function (imeObject) {
          installFocusKeyCallbacks();
          wapal_magic.ready(id);
      },
      ime = new IMEShell(id, imeReady, 'en'),
      element = document.getElementById(id);
  }
  
  wapal_magic.createInputObjects = function () {
      var index,
          previousIndex,
          nextIndex;
  
      for (index in this.elementIds) {
          previousIndex = index - 1;
          if (previousIndex &lt; 0) {
              previousIndex = wapal_magic.inputs.length - 1;
          }
          nextIndex = (index + 1) % wapal_magic.inputs.length;
          wapal_magic.inputs[index] = new Input(this.elementIds[index],
                  this.elementIds[previousIndex], this.elementIds[nextIndex]);
      }
  };
  
  wapal_magic.ready = function (id) {
      var ready = true,
      i;
  
      for (i in wapal_magic.elementIds) {
          if (wapal_magic.elementIds[i] == id) {
              wapal_magic.ready[i] = true;
          }
  
          if (wapal_magic.ready[i] == false) {
              ready = false;
          }
      }
      if (ready) {
          document.getElementById("txtInp1").focus();
      }
  };
  ////////////////////////
  wapal_magic.onLoad = function()
  {
      // Enable key event processing
      //this.enableKeys();
     // widgetAPI.sendReadyEvent();
  
      this.initTextBoxes(new Array("txtInp1", "txtInp2"));
  
  
  
  };
  wapal_magic.initTextBoxes = function(textboxes){
      this.elementIds = textboxes;
      for(i=0;i&lt;this.elementIds.length;i++){
          this.inputs[i]=false;
          this.ready[i]=null;
      }
  
          this.createInputObjects();
      widgetAPI.registIMEKey();
  };
  wapal_magic.onUnload = function()
  {
  
  };
  
  wapal_magic.enableKeys = function()
  {
      document.getElementById("anchor").focus();
  };
  
  wapal_magic.keyDown = function()
  {
      var keyCode = event.keyCode;
      alert("Key pressed: " + keyCode);
  
      switch(keyCode)
      {
          case tvKey.KEY_RETURN:
          case tvKey.KEY_PANEL_RETURN:
              alert("RETURN");
              widgetAPI.sendReturnEvent();
              break;
          case tvKey.KEY_LEFT:
              alert("LEFT");
              break;
          case tvKey.KEY_RIGHT:
              alert("RIGHT");
              break;
          case tvKey.KEY_UP:
              alert("UP");
              break;
          case tvKey.KEY_DOWN:
              alert("DOWN");
              break;
          case tvKey.KEY_ENTER:
          case tvKey.KEY_PANEL_ENTER:
              alert("ENTER");
              break;
          default:
              alert("Unhandled key");
              break;
      }
  };
  </code></pre>