KeyEvent getUnicodeChar - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for KeyEvent getUnicodeChar method.

This code example shows how to use the following methods:getAction, getKeyCode, getMetaState, getUnicodeChar
        super.onDestroy(); 
    } 
 
    @Override 
    public boolean dispatchKeyEvent(KeyEvent event) {
        switch (event.getAction()) {
            case KeyEvent.ACTION_DOWN:
                int uni = event.getUnicodeChar(event.getMetaState());
                return handleKeyDown(event.getKeyCode(), uni);
            case KeyEvent.ACTION_UP:
                return handleKeyUp(event.getKeyCode());
            default: 
                return false; 
        } 
    } 
 
    @Override 
    public void setTitle(CharSequence title) {
        mTitle.setText(title);
    } 
7
CodeRank
This code example shows how to use the following methods:getAction, getEventTime, getKeyCode, getMetaState, getUnicodeChar
    } 
 
    boolean translateAndSendNativeEvents(KeyEvent event) {
        if (mNativeImeAdapterAndroid == 0) return false;
 
        int action = event.getAction();
        if (action != KeyEvent.ACTION_DOWN &&
            action != KeyEvent.ACTION_UP) {
            // action == KeyEvent.ACTION_MULTIPLE 
            // TODO(bulach): confirm the actual behavior. Apparently: 
            // If event.getKeyCode() == KEYCODE_UNKNOWN, we can send a 
            // composition key down (229) followed by a commit text with the 
            // string from event.getUnicodeChars(). 
            // Otherwise, we'd need to send an event with a 
            // WebInputEvent::IsAutoRepeat modifier. We also need to verify when 
            // we receive ACTION_MULTIPLE: we may receive it after an ACTION_DOWN, 
            // and if that's the case, we'll need to review when to send the Char 
            // event. 
            return false; 
        } 

7
CodeRank
This code example shows how to use the following methods:getAction, getKeyCode, getUnicodeChar
        if (DEBUG) Log.w(TAG, "sendKeyEvent [" + event.getAction() + "]");
 
        // If this is a key-up, and backspace/del or if the key has a character representation, 
        // need to update the underlying Editable (i.e. the local representation of the text 
        // being edited). 
        if (event.getAction() == KeyEvent.ACTION_UP) {
            if (event.getKeyCode() == KeyEvent.KEYCODE_DEL) {
                super.deleteSurroundingText(1, 0); 
            } else if (event.getKeyCode() == KeyEvent.KEYCODE_FORWARD_DEL) {
                super.deleteSurroundingText(0, 1); 
            } else { 
                int unicodeChar = event.getUnicodeChar();
                if (unicodeChar != 0) {
                    Editable editable = getEditable();
                    int selectionStart = Selection.getSelectionStart(editable);
                    int selectionEnd = Selection.getSelectionEnd(editable);
                    if (selectionStart > selectionEnd) {
                        int temp = selectionStart;
                        selectionStart = selectionEnd;
                        selectionEnd = temp;

7
CodeRank
This code example shows how to use the following methods:handleKeyDown, getMetaState, getUnicodeChar
     * This translates incoming hard key events in to edit operations on an 
     * InputConnection.  It is only needed when using the 
     * PROCESS_HARD_KEYS option. 
     */ 
    private boolean translateKeyDown(int keyCode, KeyEvent event) {
        mMetaState = MetaKeyKeyListener.handleKeyDown(mMetaState,
                keyCode, event);
        int c = event.getUnicodeChar(MetaKeyKeyListener.getMetaState(mMetaState));
        mMetaState = MetaKeyKeyListener.adjustMetaAfterKeypress(mMetaState);
        InputConnection ic = getCurrentInputConnection();
        if (c == 0 || ic == null) {
            return false; 
        } 
         
        boolean dead = false;
 
        if ((c & KeyCharacterMap.COMBINING_ACCENT) != 0) {
            dead = true;
            c = c & KeyCharacterMap.COMBINING_ACCENT_MASK;
        } 

6
CodeRank
This code example shows how to use the following methods:getAction, getKeyCode, getUnicodeChar
    @Override 
    public boolean onKeyDown(int keyCode, KeyEvent event)
    { 
        boolean ret = super.onKeyDown(keyCode, event);
        if (!ret)
            ret = keyEvent(event.getAction(), event.getUnicodeChar(), event.getKeyCode(), event);
        return ret;
    } 
 
    @Override 
    public boolean onKeyUp(int keyCode, KeyEvent event)
    { 
        boolean ret = super.onKeyUp(keyCode, event);
        if (!ret)
            ret = keyEvent(event.getAction(), event.getUnicodeChar(), event.getKeyCode(), event);
        return ret;
    } 
 
	public void onAccuracyChanged(Sensor sensor, int accuracy) {
		// Auto-generated method stub 
6
CodeRank
This code example shows how to use the following methods:handleKeyDown, getUnicodeChar
	 * This translates incoming hard key events in to edit operations on an 
	 * InputConnection.  It is only needed when using the 
	 * PROCESS_HARD_KEYS option. 
	 */ 
	private boolean translateKeyDown(int keyCode, @Nonnull KeyEvent event) {
		metaState = MetaKeyKeyListener.handleKeyDown(metaState, keyCode, event);
		int unicodeChar = event.getUnicodeChar(MetaKeyKeyListener.getMetaState(metaState));
 
		metaState = MetaKeyKeyListener.adjustMetaAfterKeypress(metaState);
		if (unicodeChar == 0 || !keyboardInput.isInputConnected()) {
			return false; 
		} 
 
		if ((unicodeChar & KeyCharacterMap.COMBINING_ACCENT) != 0) {
			unicodeChar = unicodeChar & KeyCharacterMap.COMBINING_ACCENT_MASK;
		} 
 
		unicodeChar = keyboardInput.translateKeyDown(unicodeChar);
 
		onKey(unicodeChar, null);
5
CodeRank
This code example shows how to use the following methods:getMetaState, getUnicodeChar
		case KeyEvent.KEYCODE_BACK:
			result = mBackKeyCode;
			break; 
 
		default: { 
			int metaState = event.getMetaState();
			chordedCtrl = ((META_CTRL_ON & metaState) != 0);
			boolean effectiveCaps = allowToggle && (mCapKey.isActive());
			boolean effectiveAlt = allowToggle && mAltKey.isActive();
			int effectiveMetaState = metaState & (~META_CTRL_MASK);
			if (effectiveCaps) {
				effectiveMetaState |= KeyEvent.META_SHIFT_ON;
			} 
			if (!allowToggle && (effectiveMetaState & META_ALT_ON) != 0) {
				effectiveAlt = true;
			} 
			if (effectiveAlt) {
				if (mAltSendsEsc) {
					mTermSession.write(new byte[] { 0x1b }, 0, 1);
					effectiveMetaState &= ~KeyEvent.META_ALT_MASK;

5
CodeRank
This code example shows how to use the following methods:getUnicodeChar
		}); 
		 
		mSearchBox.setOnKeyListener(new View.OnKeyListener() {
			@Override 
			public boolean onKey(View v, int keyCode, KeyEvent event) {
				if(event.getUnicodeChar() != 0) {
					String initialSearch = new String(new int[] { event.getUnicodeChar() }, 0, 1);
					activity.startSearch(initialSearch, false, null, false);
					return true; 
				} 
				return false; 
			} 
		}); 
		 
		mSearchBox.setOnLongClickListener(new View.OnLongClickListener() {
			@Override 
			public boolean onLongClick(View v) {
				activity.onSearchRequested();
				return true; 
			} 
5
CodeRank
This code example shows how to use the following methods:handleKeyDown, getMetaState, getUnicodeChar
	 * This translates incoming hard key events in to edit operations on an 
	 * InputConnection. It is only needed when using the PROCESS_HARD_KEYS 
	 * option. 
	 */ 
	private boolean translateKeyDown(int keyCode, KeyEvent event) {
		mMetaState = MetaKeyKeyListener.handleKeyDown(mMetaState, keyCode,
				event);
		int c = event.getUnicodeChar(MetaKeyKeyListener
				.getMetaState(mMetaState));
		mMetaState = MetaKeyKeyListener.adjustMetaAfterKeypress(mMetaState);
		InputConnection ic = getCurrentInputConnection();
		if (c == 0 || ic == null) {
			return false; 
		} 
 
		if ((c & KeyCharacterMap.COMBINING_ACCENT) != 0) {
			c = c & KeyCharacterMap.COMBINING_ACCENT_MASK;
		} 
 
		if (mComposing.length() > 0) {

5
CodeRank
This code example shows how to use the following methods:handleKeyDown, getMetaState, getUnicodeChar
     * This translates incoming hard key events in to edit operations on an 
     * InputConnection.  It is only needed when using the 
     * PROCESS_HARD_KEYS option. 
     */ 
    private boolean translateKeyDown(int keyCode, KeyEvent event) {
        mMetaState = MetaKeyKeyListener.handleKeyDown(mMetaState,
                keyCode, event);
        int c = event.getUnicodeChar(MetaKeyKeyListener.getMetaState(mMetaState));
        mMetaState = MetaKeyKeyListener.adjustMetaAfterKeypress(mMetaState);
        InputConnection ic = getCurrentInputConnection();
        if (c == 0 || ic == null) {
            return false; 
        } 
         
        boolean dead = false;
 
        if ((c & KeyCharacterMap.COMBINING_ACCENT) != 0) {
            dead = true;
            c = c & KeyCharacterMap.COMBINING_ACCENT_MASK;
        } 

5
CodeRank

Related KeyEvent getUnicodeChar Questions & Answers:

getUnicodeChar Method Overview
Gets the Unicode character generated by the specified key and meta key state combination.
See Code Examples for other Android KeyEvent Methods: