Code example for KeyEvent

Methods: getActiongetKeyCodegetRepeatCount

0
	 
	// Handle all key presses. 
	@Override 
	public boolean dispatchKeyEvent(KeyEvent event)
	{ 
		if (mThemeView == null) return super.dispatchKeyEvent(event);
		 
		// Make sure we don't handle repeat clicks, 
		// ie. holding a button down. 
		if (event.getRepeatCount() == 0 &&
				event.getAction() == KeyEvent.ACTION_DOWN)
		{ 
			switch(event.getKeyCode())
			{ 
				// Hide menus when back button is pressed. 
				case KeyEvent.KEYCODE_BACK:
				{ 
					mThemeView.animateClose();
					return true; 
				} 
			} 
		} 
		 
		return super.dispatchKeyEvent(event);
	} 
     
    // Collapse menu if open and back pressed. 
    @Override 
    public void onBackPressed() {