title: samsung smart tv sdk 4.1 application not working on sdk 5.1
body: <p>I have made an application on Samsung Smart TV SDK 4.1, but that application is not working on Samsung Smart TV SDK 5.1.</p>
  
  <p>Can any one help me with remote working in sdk 5.1</p>
  
  <p>I have tried some demo apps from <a href="http://www.samsungdforum.com/" rel="nofollow">samsungdforum</a> but its not helping me.</p>
  
  <p>Code:
  The code is: </p>
  
  <p><strong>Main.js</strong></p>
  
  <pre><code>var widgetAPI = new Common.API.Widget();
  var tvKey = new Common.API.TVKeyValue();
  
  var current_selected_index=0;
  var menu_count=5;
  
  var Main =
  {
  
  };
  
  Main.onLoad = function()
  {
      // Enable key event processing
      this.enableKeys();
      widgetAPI.sendReadyEvent();
  };
  
  Main.onUnload = function()
  {
  
  };
  
  Main.enableKeys = function()
  {
      document.getElementById("menu").focus();
      $('.menu').eq(current_selected_index).addClass('selected');
      $('.menu a').eq(current_selected_index).focus();
  };
  
  Main.keyDown = function()
  {
      var keyCode = event.keyCode;
      alert("Key pressed: " + keyCode);
  
      switch(keyCode)
      {
        case tvKey.KEY_UP:
          alert("UP");
          $('.menu').eq(current_selected_index).removeClass("selected");
          if(current_selected_index==0){
              current_selected_index=3;
          }
          else{
              current_selected_index--;
          }
          $('.menu').eq(current_selected_index).addClass("selected");
          break;
         case tvKey.KEY_DOWN:
              alert("DOWN");
              $('.menu').eq(current_selected_index).removeClass("selected");
              if(current_selected_index==3){
                  current_selected_index=0;
              }
              else{
                  current_selected_index--;
              }
              $('.menu').eq(current_selected_index).addClass("selected");
         break;   
         case tvKey.KEY_LEFT:
              alert("LEFT");
              $('.menu').eq(current_selected_index).removeClass("selected");
              if(current_selected_index==0){
                  current_selected_index=4;
              }
              else{
                  current_selected_index--;
              }
              $('.menu').eq(current_selected_index).addClass("selected");
              $('.menu a').eq(current_selected_index).focus();
              break;
          case tvKey.KEY_RIGHT:
              alert("RIGHT");
              $('.menu').eq(current_selected_index).removeClass("selected");
              if(current_selected_index==4){
                  current_selected_index=0;
              }
              else{
                  current_selected_index++;
              }
              $('.menu').eq(current_selected_index).addClass("selected");
              $('.menu a').eq(current_selected_index).focus();
              break;
          case tvKey.KEY_ENTER:
  
  
  
              var $j;
              $('#display').html($('.menu a').eq(current_selected_index).html());
              $j=$('.menu a').eq(current_selected_index).html();
              window.location=$j+".html";
              alert($(this).html());
              break;
  
          case tvKey.KEY_PANEL_ENTER:
              $('#display').html($('.menu a').eq(current_selected_index).html());
              alert($(this).html());
              break;
          default:
              alert("Unhandled key");
              break;
      }
  };
  
  Main.mouseclick=function()
  {
      $('#display').html($('.menu a').eq(current_selected_index).html());
      window.location="hyderabad.html";
  }; 
  
  **Main.css**
  
  *
  {
      padding: 0;
      margin: 0;
      border: 0;
  }
  
  body
  {
      width: 960px;
      height: 540px;
  }
  
  #container
      {
      width:800px;
      height:400px;
      position:absolute;
      left:50%;
      margin-left:-250px;
      top:50%;
      margin-top:-150px;
      border:1pxsolid#fff;
      border-radius:5px;
  
      }
  
  .retunbtn
      {
      position:absolute;
      left:80%;
      margin-left:-150px;
      top:80%;
      margin-top:-180px;
      border:1pxsolid#fff;
      border-radius:5px;
      }
  
      .menu
      {
      float:left;
      width:100px;
      height:100px;
      margin-top:20px;
      margin-left:20px;
      text-align:center;
      line-height:6em;
      background-image: -webkit-linear-gradient(bottom,rgb(135,135,135) 7%, rgb(184,184,184) 54%);
      border-radius:5px;
  
      }
  
      .menu a{
      color:#8B0000;
      text-decoration:none;
      text-transform:uppercase;
  
      }   
  
      #display{
      clear:both;
      width:400px;
      height:100px;
      margin-left:50px;
      position:absolute;
      bottom:50px;
      border:1pxsolid#fff;
      border-radius:5px;
      text-align:center;
      color:blue;
      font-weight:bold;
      line-weight:3em;
  
      }
  
      .selected
      {
      background-image:-webkit-linear-gradient(bottom,rgb(135,135,135)7%,rgb(184,184,184)54%);
      color:black;
      }
  
      #content{
      color:#800000;
      font:bold;
      align-text:center;
      position:absolute;
      left:50%;
      margin-left:-250px;
      top:30%;
      margin-top:-150px;
  
      }
  
      .menu1 {
        float:left;
        width:20%;
        height:100%;
      }
      .mainContent {
        float:left;
        width:80%;
        height:100%;
      }
  
      a:link, a:visited {
      color: (internal value);
      text-decoration: underline;
      cursor: auto;
  }
  
  a:link:active, a:visited:active {
      color: (internal value);
  } 
  
  
  **index.html**
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
          &lt;title&gt;tourism&lt;/title&gt;
          &lt;script type="text/javascript" src="app/javascript/jquery-1.9.1.js"&gt;&lt;/script&gt;  
          &lt;!-- TODO : Common API --&gt;
          &lt;script type="text/javascript" language="javascript" src="$MANAGER_WIDGET/Common/API/Widget.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" language="javascript" src="$MANAGER_WIDGET/Common/API/TVKeyValue.js"&gt;&lt;/script&gt;
          &lt;!-- TODO : Javascript code --&gt;
          &lt;script language="javascript" type="text/javascript" src="app/javascript/Main.js"&gt;&lt;/script&gt;
          &lt;!-- TODO : Style sheets code --&gt;
          &lt;link rel="stylesheet" href="app/stylesheets/Main.css" type="text/css"&gt;
          &lt;!-- TODO: Plugins --&gt;
      &lt;/head&gt;
      &lt;body onload="Main.onLoad();" onunload="Main.onUnload();"&gt;
          &lt;!-- Dummy anchor as focus for key events --&gt;
          &lt;a href="javascript:void(0);" id="menu" onkeydown="Main.keyDown();"&gt;&lt;/a&gt;
          &lt;div id="content"&gt;
          &lt;h1&gt;INDIA TOURISM APPLICATION&lt;/h1&gt;
  
          &lt;/div&gt;
  
           &lt;div id="container"&gt;
               &lt;div class="menu"&gt;
  
  
               &lt;a href="javascript.void(0);" onkeydown="Main.keyDown();" &gt;HYDERABAD&lt;/a&gt;
  
                &lt;/div&gt;
                &lt;div class="menu"&gt;
               &lt;a href="javascript.void(0);" onkeydown="Main.keyDown();"&gt;Delhi&lt;/a&gt;
                &lt;/div&gt;
                &lt;div class="menu"&gt;
  
               &lt;a href="javascript.void(0);" onkeydown="Main.keyDown();"&gt;Jaipur&lt;/a&gt;
               &lt;/div&gt;
  
                &lt;div class="menu"&gt;
  
               &lt;a href="javascript.void(0);" onkeydown="Main.keyDown();"&gt;Jaipurs&lt;/a&gt;
               &lt;/div&gt;
  
                &lt;div class="menu"&gt;
  
               &lt;a href="javascript.void(0);" onkeydown="Main.keyDown();"&gt;Jaipur1&lt;/a&gt;
               &lt;/div&gt;
  
           &lt;/div&gt; 
  
      enter code here
  
          &lt;img src="images/wallpaper.jpg" style="width:960px;height:540px" &gt;
          &lt;!-- TODO: your code here --&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>