title: KeyEvent of D-pad for Android TV
body: <p>In activity I have TabLayout, ViewPager and menu button (hamburger) in toolbar.</p>
  <p>With arrows on my keyboard I am moving from tabs to view pager items without problems by default but I cannot achieve focus on toolbar menu button.</p>
  <p>First of all I can't listen when KeyEvent.KEYCODE_DPAD_UP was pressed and I'm wondering why.</p>
  <p><strong>My code:</strong></p>
  <pre><code>viewPager = findViewById(R.id.viewpager);
  viewPager.setAdapter(adapter);
  tabLayout = findViewById(R.id.tabs);
  tabLayout.setupWithViewPager(viewPager);
  
  tabLayout.setOnKeyListener(new View.OnKeyListener() {
      @Override
      public boolean onKey(View view, int i, KeyEvent keyEvent) {
          if ((keyEvent.getAction() == KeyEvent.ACTION_UP) &amp;&amp; (i == KeyEvent.KEYCODE_DPAD_UP)) {
              toolbar.setFocusable(true);
              toolbar.setFocusableInTouchMode(true);
              tabLayout.setNextFocusUpId(R.id.toolbar);
              Log.d(TAG, &quot;KEYCODE_DPAD_UP&quot;);
              tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
              tabLayout.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
          }
          return false;
      }
  });
  </code></pre>
  <p><strong>What is wrong with my if-statement?</strong></p>