Example usage for android.view KeyEvent getAction

List of usage examples for android.view KeyEvent getAction

Introduction

In this page you can find the example usage for android.view KeyEvent getAction.

Prototype

public final int getAction() 

Source Link

Document

Retrieve the action of this key event.

Usage

From source file:org.bangbang.support.v4.widget.VerticalViewPager.java

/**
 * You can call this function yourself to have the scroll view perform
 * scrolling from a key event, just as if the event had been dispatched to
 * it by the view hierarchy.//  w ww.  j  av  a  2s  .co m
 *
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event) {
    boolean handled = false;
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_DPAD_UP:
            handled = arrowScroll(FOCUS_UP);
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            handled = arrowScroll(FOCUS_DOWN);
            break;
        case KeyEvent.KEYCODE_TAB:
            if (Build.VERSION.SDK_INT >= 11) {
                // The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD
                // before Android 3.0. Ignore the tab key on those devices.
                if (KeyEventCompat.hasNoModifiers(event)) {
                    handled = arrowScroll(FOCUS_FORWARD);
                } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) {
                    handled = arrowScroll(FOCUS_BACKWARD);
                }
            }
            break;
        }
    }
    return handled;
}

From source file:com.tandong.sa.sherlock.widget.SearchView.java

/**
 * React to the user typing while in the suggestions list. First, check for
 * action keys. If not handled, try refocusing regular characters into the
 * EditText./*w  w  w. j  a v  a2 s .  c o  m*/
 */
private boolean onSuggestionsKey(View v, int keyCode, KeyEvent event) {
    // guard against possible race conditions (late arrival after dismiss)
    if (mSearchable == null) {
        return false;
    }
    if (mSuggestionsAdapter == null) {
        return false;
    }
    if (event.getAction() == KeyEvent.ACTION_DOWN && KeyEventCompat.hasNoModifiers(event)) {
        // First, check for enter or search (both of which we'll treat as a
        // "click")
        if (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_SEARCH
                || keyCode == KeyEvent.KEYCODE_TAB) {
            int position = mQueryTextView.getListSelection();
            return onItemClicked(position, KeyEvent.KEYCODE_UNKNOWN, null);
        }

        // Next, check for left/right moves, which we use to "return" the
        // user to the edit view
        if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
            // give "focus" to text editor, with cursor at the beginning if
            // left key, at end if right key
            // TODO: Reverse left/right for right-to-left languages, e.g.
            // Arabic
            int selPoint = (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) ? 0 : mQueryTextView.length();
            mQueryTextView.setSelection(selPoint);
            mQueryTextView.setListSelection(0);
            mQueryTextView.clearListSelection();
            ensureImeVisible(mQueryTextView, true);

            return true;
        }

        // Next, check for an "up and out" move
        if (keyCode == KeyEvent.KEYCODE_DPAD_UP && 0 == mQueryTextView.getListSelection()) {
            // TODO: restoreUserQuery();
            // let ACTV complete the move
            return false;
        }

        // Next, check for an "action key"
        // TODO SearchableInfo.ActionKeyInfo actionKey =
        // mSearchable.findActionKey(keyCode);
        // TODO if ((actionKey != null)
        // TODO && ((actionKey.getSuggestActionMsg() != null) || (actionKey
        // TODO .getSuggestActionMsgColumn() != null))) {
        // TODO // launch suggestion using action key column
        // TODO int position = mQueryTextView.getListSelection();
        // TODO if (position != ListView.INVALID_POSITION) {
        // TODO Cursor c = mSuggestionsAdapter.getCursor();
        // TODO if (c.moveToPosition(position)) {
        // TODO final String actionMsg = getActionKeyMessage(c, actionKey);
        // TODO if (actionMsg != null && (actionMsg.length() > 0)) {
        // TODO return onItemClicked(position, keyCode, actionMsg);
        // TODO }
        // TODO }
        // TODO }
        // TODO }
    }
    return false;
}

From source file:com.gome.ecmall.custom.VerticalViewPager.java

/**
 * You can call this function yourself to have the scroll view perform scrolling from a key event, just as if the
 * event had been dispatched to it by the view hierarchy.
 * // w w  w  .  ja v  a 2 s . co m
 * @param event
 *            The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event) {
    boolean handled = false;
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_DPAD_UP:
            handled = arrowScroll(FOCUS_UP);
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            handled = arrowScroll(FOCUS_DOWN);
            break;
        case KeyEvent.KEYCODE_TAB:
            if (Build.VERSION.SDK_INT >= 11) {
                // The focus finder had a bug handling FOCUS_FORWARD and
                // FOCUS_BACKWARD
                // before Android 3.0. Ignore the tab key on those devices.
                if (KeyEventCompat.hasNoModifiers(event)) {
                    handled = arrowScroll(FOCUS_FORWARD);
                } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) {
                    handled = arrowScroll(FOCUS_BACKWARD);
                }
            }
            break;
        }
    }
    return handled;
}

From source file:com.brantapps.viewpagerindicator.vertical.VerticalViewPager.java

/**
 * You can call this function yourself to have the scroll view perform
 * scrolling from a key event, just as if the event had been dispatched to
 * it by the view hierarchy./*ww  w  .ja v  a 2  s.  c  om*/
 *
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
// BrantApps Change: Replaced all "LEFT"s with "UP"s and "RIGHT"s with "DOWN"s
public boolean executeKeyEvent(KeyEvent event) {
    boolean handled = false;
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_DPAD_UP:
            handled = arrowScroll(FOCUS_UP);
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            handled = arrowScroll(FOCUS_DOWN);
            break;
        case KeyEvent.KEYCODE_TAB:
            if (Build.VERSION.SDK_INT >= 11) {
                // The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD
                // before Android 3.0. Ignore the tab key on those devices.
                if (KeyEventCompat.hasNoModifiers(event)) {
                    handled = arrowScroll(FOCUS_FORWARD);
                } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) {
                    handled = arrowScroll(FOCUS_BACKWARD);
                }
            }
            break;
        }
    }
    return handled;
}

From source file:info.guardianproject.otr.app.im.app.ChatView.java

@Override
protected void onFinishInflate() {
    //  mStatusIcon = (ImageView) findViewById(R.id.statusIcon);
    //   mDeliveryIcon = (ImageView) findViewById(R.id.deliveryIcon);
    // mTitle = (TextView) findViewById(R.id.title);
    mHistory = (ListView) findViewById(R.id.history);
    mComposeMessage = (EditText) findViewById(R.id.composeMessage);
    mSendButton = (ImageButton) findViewById(R.id.btnSend);
    mHistory.setOnItemClickListener(mOnItemClickListener);
    mButtonAttach = (ImageButton) findViewById(R.id.btnAttach);
    mViewAttach = findViewById(R.id.attachPanel);

    mStatusWarningView = findViewById(R.id.warning);
    mWarningText = (TextView) findViewById(R.id.warningText);

    mProgressTransfer = (ProgressBar) findViewById(R.id.progressTransfer);
    // mOtrSwitch = (CompoundButton)findViewById(R.id.otrSwitch);
    mProgressBarOtr = (ProgressBar) findViewById(R.id.progressBarOtr);

    mButtonAttach.setOnClickListener(new OnClickListener() {

        @Override/* w w w . ja v a2 s. co m*/
        public void onClick(View v) {

            if (mViewAttach.getVisibility() == View.GONE)
                mViewAttach.setVisibility(View.VISIBLE);
            else
                mViewAttach.setVisibility(View.GONE);
        }

    });

    ((ImageButton) findViewById(R.id.btnAttachAudio)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mNewChatActivity.startAudioPicker();
        }

    });

    ((ImageButton) findViewById(R.id.btnAttachPicture)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mNewChatActivity.startImagePicker();
        }

    });

    ((ImageButton) findViewById(R.id.btnTakePicture)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mNewChatActivity.startPhotoTaker();
        }

    });

    ((ImageButton) findViewById(R.id.btnAttachFile)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mNewChatActivity.startFilePicker();
        }

    });

    mHistory.setOnItemLongClickListener(new OnItemLongClickListener() {

        @TargetApi(Build.VERSION_CODES.HONEYCOMB)
        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {

            if (arg1 instanceof MessageView) {

                String textToCopy = ((MessageView) arg1).getLastMessage();

                int sdk = android.os.Build.VERSION.SDK_INT;
                if (sdk < android.os.Build.VERSION_CODES.HONEYCOMB) {
                    android.text.ClipboardManager clipboard = (android.text.ClipboardManager) mNewChatActivity
                            .getSystemService(Context.CLIPBOARD_SERVICE);
                    clipboard.setText(textToCopy); //
                } else {
                    android.content.ClipboardManager clipboard = (android.content.ClipboardManager) mNewChatActivity
                            .getSystemService(Context.CLIPBOARD_SERVICE);
                    android.content.ClipData clip = android.content.ClipData.newPlainText("chat", textToCopy);
                    clipboard.setPrimaryClip(clip); //
                }

                Toast.makeText(mNewChatActivity, mContext.getString(R.string.toast_chat_copied_to_clipboard),
                        Toast.LENGTH_SHORT).show();

                return true;

            }

            return false;
        }

    });

    mWarningText.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            showVerifyDialog();
        }
    });

    //mOtrSwitch.setOnCheckedChangeListener(mOtrListener);

    mComposeMessage.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_DOWN) {
                switch (keyCode) {
                case KeyEvent.KEYCODE_DPAD_CENTER:
                    sendMessage();
                    return true;

                case KeyEvent.KEYCODE_ENTER:
                    if (event.isAltPressed()) {
                        mComposeMessage.append("\n");
                        return true;
                    }
                }
            }
            return false;
        }
    });

    mComposeMessage.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (event != null) {
                if (event.isAltPressed()) {
                    return false;
                }
            }

            InputMethodManager imm = (InputMethodManager) mContext
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            if (imm != null && imm.isActive(v)) {
                imm.hideSoftInputFromWindow(getWindowToken(), 0);
            }
            sendMessage();
            return true;
        }
    });

    // TODO: this is a hack to implement BUG #1611278, when dispatchKeyEvent() works with
    // the soft keyboard, we should remove this hack.
    mComposeMessage.addTextChangedListener(new TextWatcher() {
        public void beforeTextChanged(CharSequence s, int start, int before, int after) {
        }

        public void onTextChanged(CharSequence s, int start, int before, int after) {
            //log("TextWatcher: " + s);
            userActionDetected();
        }

        public void afterTextChanged(Editable s) {
        }
    });

    mSendButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            sendMessage();
        }
    });

    Button btnApproveSubscription = (Button) findViewById(R.id.btnApproveSubscription);
    btnApproveSubscription.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            mNewChatActivity.approveSubscription(mProviderId, mRemoteAddress);

            mHandler.postDelayed(new Runnable() {
                public void run() {
                    bindChat(mLastChatId);
                }
            }, 2000);

        }

    });

    Button btnDeclineSubscription = (Button) findViewById(R.id.btnDeclineSubscription);
    btnDeclineSubscription.setOnClickListener(new OnClickListener() {

        @Override

        public void onClick(View v) {

            mHandler.postDelayed(new Runnable() {
                public void run() {
                    mNewChatActivity.declineSubscription(mProviderId, mRemoteAddress);

                }
            }, 500);

        }

    });

    /*
    mActionBox = (View)findViewById(R.id.actionBox);
    ImageButton btnActionBox = (ImageButton)findViewById(R.id.btnActionBox);
    btnActionBox.setOnClickListener(new OnClickListener ()
    {
            
    @Override
    public void onClick(View v) {
            
        mEmojiPager.setVisibility(View.GONE);
            
            
        if (mActionBox.getVisibility() == View.GONE)
            mActionBox.setVisibility(View.VISIBLE);
        else
            mActionBox.setVisibility(View.GONE);
    }
            
    });
            
    View btnEndChat = findViewById(R.id.btnEndChat);
    btnEndChat.setOnClickListener(new OnClickListener ()
    {
            
    @Override
    public void onClick(View v) {
            
        ChatView.this.closeChatSession();
    }
            
    });
            
    View btnProfile = findViewById(R.id.btnProfile);
    btnProfile.setOnClickListener(new OnClickListener ()
    {
            
    @Override
    public void onClick(View v) {
            
        viewProfile();
    }
            
    });
            
    View btnSharePicture = findViewById(R.id.btnSendPicture);
    btnSharePicture.setOnClickListener(new OnClickListener ()
    {
            
    @Override
    public void onClick(View v) {
            
        if (mLastSessionStatus != null && mLastSessionStatus == SessionStatus.ENCRYPTED)
        {
            mNewChatActivity.startImagePicker();
        }
        else
        {
            mHandler.showServiceErrorAlert(getContext().getString(R.string.please_enable_chat_encryption_to_share_files));
        }
    }
            
    });
            
    View btnShareFile = findViewById(R.id.btnSendFile);
    btnShareFile.setOnClickListener(new OnClickListener ()
    {
            
    @Override
    public void onClick(View v) {
            
        if (mLastSessionStatus != null && mLastSessionStatus == SessionStatus.ENCRYPTED)
        {
            mNewChatActivity.startFilePicker();
        }
        else
        {
            mHandler.showServiceErrorAlert(getContext().getString(R.string.please_enable_chat_encryption_to_share_files));
            
        }
    }
            
    });
    */

    initEmoji();

    mMessageAdapter = new MessageAdapter(mNewChatActivity, null);
    mHistory.setAdapter(mMessageAdapter);
}

From source file:com.google.android.libraries.cast.companionlibrary.cast.VideoCastManager.java

/**
 * Clients can call this method to delegate handling of the volume. Clients should override
 * {@code dispatchEvent} and call this method:
 * <pre>//from w  w  w  .j a v  a  2  s. co m
 public boolean dispatchKeyEvent(KeyEvent event) {
 if (mCastManager.onDispatchVolumeKeyEvent(event, VOLUME_DELTA)) {
    return true;
 }
 return super.dispatchKeyEvent(event);
 }
 * </pre>
 * @param event The dispatched event.
 * @param volumeDelta The amount by which volume should be increased or decreased in each step
 * @return <code>true</code> if volume is handled by the library, <code>false</code> otherwise.
 */
public boolean onDispatchVolumeKeyEvent(KeyEvent event, double volumeDelta) {
    if (isConnected()) {
        boolean isKeyDown = event.getAction() == KeyEvent.ACTION_DOWN;
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_VOLUME_UP:
            if (changeVolume(volumeDelta, isKeyDown)) {
                return true;
            }
            break;
        case KeyEvent.KEYCODE_VOLUME_DOWN:
            if (changeVolume(-volumeDelta, isKeyDown)) {
                return true;
            }
            break;
        }
    }
    return false;
}

From source file:com.android.internal.widget.ViewPager.java

/**
 * You can call this function yourself to have the scroll view perform
 * scrolling from a key event, just as if the event had been dispatched to
 * it by the view hierarchy.// w w  w  .j  a  va  2  s  . c o m
 *
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event) {
    boolean handled = false;
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
            handled = arrowScroll(FOCUS_LEFT);
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            handled = arrowScroll(FOCUS_RIGHT);
            break;
        case KeyEvent.KEYCODE_TAB:
            if (event.hasNoModifiers()) {
                handled = arrowScroll(FOCUS_FORWARD);
            } else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) {
                handled = arrowScroll(FOCUS_BACKWARD);
            }
            break;
        }
    }
    return handled;
}

From source file:com.plusot.senselib.SenseMain.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    final int action = event.getAction();
    final int keyCode = event.getKeyCode();
    boolean result = false;

    if ((lastAction == action && lastKeyCode == keyCode)) {
        switch (keyCode) {
        case KeyEvent.KEYCODE_CAMERA:
            newInterval();//from  w  w w.  j a v  a  2  s.  c  o  m
            break;
        case KeyEvent.KEYCODE_POWER:
            //if (action == KeyEvent.)
            LLog.d(Globals.TAG, CLASSTAG + " Power button pressed");
            break;
        case KeyEvent.KEYCODE_VOLUME_UP:
            if (action == KeyEvent.ACTION_DOWN) {
                dimScreen(true);
            }
            result = true;
            break;
        case KeyEvent.KEYCODE_VOLUME_DOWN:
            if (action == KeyEvent.ACTION_DOWN) {
                dimScreen(false);
            }
            result = true;
            break;
        }
    } else {
        AudioManager mgr = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
        switch (keyCode) {
        case KeyEvent.KEYCODE_CAMERA:
            newInterval();
            break;
        case KeyEvent.KEYCODE_VOLUME_UP:
            if (sameActionKeyCode < 2 && lastAction == KeyEvent.ACTION_DOWN && action == KeyEvent.ACTION_UP
                    && lastKeyCode == KeyEvent.KEYCODE_VOLUME_UP) {
                mgr.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE,
                        AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_PLAY_SOUND);
            }
            result = true;
            break;
        case KeyEvent.KEYCODE_VOLUME_DOWN:
            if (sameActionKeyCode < 2 && lastAction == KeyEvent.ACTION_DOWN && action == KeyEvent.ACTION_UP
                    && lastKeyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
                mgr.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER,
                        AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_PLAY_SOUND);
            }
            result = true;
            break;
        }
    }
    if (!result) {
        // LLog.d(Globals.TAG, CLASSTAG +
        // ".distpatchKeyEvent: Calling super with " + delta);
        result = super.dispatchKeyEvent(event);
    }
    if (lastAction == action && lastKeyCode == keyCode) {
        sameActionKeyCode++;
    } else
        sameActionKeyCode = 0;

    lastKeyCode = keyCode;
    lastAction = action;
    return result;

}

From source file:research.sg.edu.edapp.kb.KbSoftKeyboard.java

/**
 * Use this to monitor key events being delivered to the application.
 * We get first crack at them, and can either resume them or let them
 * continue to the app.//from   w  ww .  ja v  a2  s .c o m
 */
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    String s = "" + event.getUnicodeChar();
    Log.d("CAME HERE", "CAME HERE");
    switch (keyCode) {
    case KeyEvent.KEYCODE_BACK:
        // The InputMethodService already takes care of the back
        // key for us, to dismiss the input method if it is shown.
        // However, our keyboard could be showing a pop-up window
        // that back should dismiss, so we first allow it to do that.

        if (event.getRepeatCount() == 0 && mInputView != null) {
            if (mInputView.handleBack()) {
                return true;
            }
        }
        break;

    case KeyEvent.KEYCODE_DEL:
        // Special handling of the delete key: if we currently are
        // composing text for the user, we want to modify that instead
        // of let the application to the delete itself.
        if (mComposing.length() > 0) {
            onKey(Keyboard.KEYCODE_DELETE, null);
            return true;
        }
        break;

    case KeyEvent.KEYCODE_ENTER:
        // Let the underlying text editor always handle these.
        return false;

    default:
        // For all other keys, if we want to do transformations on
        // text being entered with a hard keyboard, we need to process
        // it and do the appropriate action.

        if (PROCESS_HARD_KEYS) {
            //*********added changes here
            if (event.getAction() == KeyEvent.ACTION_DOWN) {
                swipe += (char) event.getUnicodeChar();
                Log.d("msg", swipe);
                System.out.println(swipe);
                // keyDownUp(keyCode);
                //   return true;
            }
            //*********done
            if (keyCode == KeyEvent.KEYCODE_SPACE && (event.getMetaState() & KeyEvent.META_ALT_ON) != 0) {
                // A silly example: in our input method, Alt+Space
                // is a shortcut for 'android' in lower case.
                InputConnection ic = getCurrentInputConnection();
                if (ic != null) {
                    // First, tell the editor that it is no longer in the
                    // shift state, since we are consuming this.
                    ic.clearMetaKeyStates(KeyEvent.META_ALT_ON);
                    keyDownUp(KeyEvent.KEYCODE_A);
                    keyDownUp(KeyEvent.KEYCODE_N);
                    keyDownUp(KeyEvent.KEYCODE_D);
                    keyDownUp(KeyEvent.KEYCODE_R);
                    keyDownUp(KeyEvent.KEYCODE_O);
                    keyDownUp(KeyEvent.KEYCODE_I);
                    keyDownUp(KeyEvent.KEYCODE_D);
                    // And we consume this event.
                    return true;
                }

            }

            if (mPredictionOn && translateKeyDown(keyCode, event)) {
                return true;
            }

        }
    }

    return super.onKeyDown(keyCode, event);
}

From source file:com.lambergar.verticalviewpager.VerticalViewPager.java

/**
 * You can call this function yourself to have the scroll view perform
 * scrolling from a key event, just as if the event had been dispatched to
 * it by the view hierarchy.//from   w ww.  ja  va 2 s.c o m
 *
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event) {
    boolean handled = false;
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
            handled = arrowScroll(FOCUS_LEFT);
            break;
        case KeyEvent.KEYCODE_DPAD_UP:
            handled = arrowScroll(FOCUS_UP);
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            handled = arrowScroll(FOCUS_RIGHT);
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            handled = arrowScroll(FOCUS_DOWN);
            break;
        case KeyEvent.KEYCODE_TAB:
            if (KeyEvent.metaStateHasNoModifiers(event.getMetaState())) {
                handled = arrowScroll(FOCUS_FORWARD);
            } else if (KeyEvent.metaStateHasModifiers(event.getMetaState(), KeyEvent.META_SHIFT_ON)) {
                handled = arrowScroll(FOCUS_BACKWARD);
            }
            break;
        }
    }
    return handled;
}