Property definitions

android $ AndroidKeyEvent :: defaultinit
# An hardware key event
extern class AndroidKeyEvent `{AInputEvent *`}
	super KeyEvent
	super AndroidInputEvent

	private fun action: Int `{ return AKeyEvent_getAction(self); `}

	redef fun is_down do return action == 0
	redef fun is_up do return action == 1

	# Hardware code of the key raising this event
	fun key_code: Int `{ return AKeyEvent_getKeyCode(self); `}

	redef fun to_c
	do
		var i = native_to_c
		if i == 0 then return null
		return i.code_point
	end

	private fun native_to_c: Int `{
		int code = AKeyEvent_getKeyCode(self);
		if (code >= AKEYCODE_0 && code <= AKEYCODE_9)
			return '0'+code-AKEYCODE_0;
		if (code >= AKEYCODE_A && code <= AKEYCODE_Z)
			return 'a'+code-AKEYCODE_A;
		return 0;
	`}

	redef fun name do return key_code.to_s

	# Was this event raised by the back key?
	fun is_back_key: Bool do return key_code == 4

	# Was this event raised by the menu key?
	fun is_menu_key: Bool do return key_code == 82

	# Was this event raised by the search key?
	fun is_search_key: Bool do return key_code == 84

	# Was this event raised by the volume up key?
	fun is_volume_up: Bool do return key_code == 24

	# Was this event raised by the volume down key?
	fun is_volume_down: Bool do return key_code == 25
end
lib/android/input_events.nit:210,1--255,3