Code example for KeyEvent

Methods: getEventTime

0
	 */ 
	public boolean onKeyUp(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
			Log.d(TAG, "D-Pad");
			// prevent too may scroll events causing multi-page changes 
			if (event.getEventTime()-lastHandledDpadEventTime>1000) {
				if (keyCode==KeyEvent.KEYCODE_DPAD_RIGHT) {
					CurrentPageManager.getInstance().getCurrentPage().next(); 
				} else { 
					CurrentPageManager.getInstance().getCurrentPage().previous(); 
				} 
				lastHandledDpadEventTime = event.getEventTime();
				return true; 
			} 
		} 
		return false; 
	} 
 
 
} 
Contextual code suggestions in your IDE  Get Codota for Java