Example usage for android.media AudioManager ADJUST_RAISE

List of usage examples for android.media AudioManager ADJUST_RAISE

Introduction

In this page you can find the example usage for android.media AudioManager ADJUST_RAISE.

Prototype

int ADJUST_RAISE

To view the source code for android.media AudioManager ADJUST_RAISE.

Click Source Link

Document

Increase the ringer volume.

Usage

From source file:com.lybeat.lilyplayer.widget.media.IjkVideoView.java

private void initGestureScanner(final Context context) {
    slop = ViewConfiguration.get(context).getScaledTouchSlop();
    screenWidth = ScreenUtil.getScreenWidth(context);
    gestureDetector = new GestureDetectorCompat(context, new LilyGestureListener());
    setOnTouchListener(new OnTouchListener() {
        @Override/* ww  w .  j  a v a  2s. c  o m*/
        public boolean onTouch(View view, MotionEvent motionEvent) {
            switch (motionEvent.getAction()) {
            case MotionEvent.ACTION_UP:
                if (adjustProgress) {
                    adjustProgress = false;
                    int newPosition = (int) (getCurrentPosition() + scrollX / screenWidth * 1000 * 90);
                    if (newPosition < 0) {
                        seekTo(0);
                    } else {
                        seekTo(newPosition);
                    }
                    start();
                    mAdjustProgressView.setVisibility(GONE);
                    if (mMediaController.isShowing()) {
                        showAllBoard();
                    }
                }
                scrollX = 0;
                scrollY = 0;
                level = 0;
                adjustVolume = false;
                adjustBrightness = false;
                break;
            case MotionEvent.ACTION_DOWN:
                lastX = motionEvent.getRawX();
                lastY = motionEvent.getRawY();
                if (motionEvent.getRawX() > screenWidth / 2 + 150) {
                    adjustVolume = true;
                    adjustBrightness = false;
                } else if (motionEvent.getRawX() < screenWidth / 2 - 150) {
                    adjustBrightness = true;
                    adjustVolume = false;
                }
                break;
            case MotionEvent.ACTION_MOVE:
                if (adjustProgress) {
                    break;
                }
                if (Math.abs(motionEvent.getRawY() - lastY) > Math.abs(motionEvent.getRawX() - lastX)) {

                    AudioManager audioManager = (AudioManager) mAppContext
                            .getSystemService(Context.AUDIO_SERVICE);
                    if (motionEvent.getRawY() > lastY) {
                        level += motionEvent.getRawY() - lastY;
                        if (level > slop) {
                            if (adjustVolume) {
                                audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC,
                                        AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI);
                            } else if (adjustBrightness) {
                                float brightness = ScreenUtil.getScreenBrightness((Activity) context);
                                if (brightness <= 0.1f) {
                                    ScreenUtil.setScreenBrightness((Activity) context, 0.0f);
                                } else {
                                    ScreenUtil.setScreenBrightness((Activity) context,
                                            ScreenUtil.getScreenBrightness((Activity) context) - 0.1f);
                                }
                            }
                            level = 0;
                        }
                    } else {
                        level += lastY - motionEvent.getRawY();
                        if (level > slop) {
                            if (adjustVolume) {
                                audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC,
                                        AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI);
                            } else if (adjustBrightness) {
                                float brightness = ScreenUtil.getScreenBrightness((Activity) context);
                                if (brightness >= 0.9f) {
                                    ScreenUtil.setScreenBrightness((Activity) context, 1.0f);
                                } else {
                                    ScreenUtil.setScreenBrightness((Activity) context,
                                            ScreenUtil.getScreenBrightness((Activity) context) + 0.1f);
                                }
                            }
                            level = 0;
                        }
                    }
                }
                lastX = motionEvent.getRawX();
                lastY = motionEvent.getRawY();
                break;
            }

            return gestureDetector.onTouchEvent(motionEvent);
        }
    });
}

From source file:com.marvin.rocklock.RockLockActivity.java

/**
 * Pick up back button and volume up and down
 *///from  w w w. j  av  a2  s  . c om
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
        mPlayer.togglePlayPause();
        return true;
    case KeyEvent.KEYCODE_MEDIA_NEXT:
        mPlayer.nextTrack(false);
        return true;
    case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
        mPlayer.prevTrack(false);
        return true;
    case KeyEvent.KEYCODE_VOLUME_UP:
        mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE,
                AudioManager.FLAG_PLAY_SOUND);
        return true;
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER,
                AudioManager.FLAG_PLAY_SOUND);
        return true;
    case KeyEvent.KEYCODE_BACK:
        onBackPressed();
        return true;
    default:
        return super.onKeyDown(keyCode, event);
    }
}

From source file:com.google.fpl.voltair.VoltAirActivity.java

/**
 * @brief Called to process (and possibly intercept) key events.
 * @param event @c KeyEvent to handle//from  w ww  .j  a  v  a  2 s. co m
 * @returns @c true if @p event was handled
 */
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        // Since QtActivity does not handle volume (throwing the events on the floor) and we
        // cannot call super.super, we must handle managing of the volume here
        // TODO: Figure out how to get the volume Ui slide to show up without permanently
        // breaking immersive mode.
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_VOLUME_UP:
            mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE,
                    0 /* No flags */);
            break;
        case KeyEvent.KEYCODE_VOLUME_DOWN:
            mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER,
                    0 /* No flags */);
            break;
        }
    }

    // QtActivity (i.e. super) will convert all key events to QKeyEvents and *always* return
    // true saying it accepted the event -- even on Gamepad key events it doesn't understand.
    // This is annoying, and unfortunately means that we must always let controllers take a look
    // at the event even if QtActivity understood it and accepted it for use (e.g. in the UI).
    // However, we must be careful with events that are successfully translated (e.g. Keyboard
    // key events) so as to not spawn two separate controllers (one here with the Android
    // KeyEvent, and the other one in "InputArea" with the translated QKeyEvent).
    if (isGamepadEvent(event)) {
        if (onGamepadKeyEvent(event)) {
            return true;
        }
    } else if (isTouchNavigationEvent(event)) {
        if (onTouchNavigationKeyEvent(event)) {
            return true;
        }
    } else if (isKeyboardEvent(event)) {
        if (onKeyboardKeyEvent(event)) {
            return true;
        }
    }
    return super.dispatchKeyEvent(event);
}

From source file:org.ulteo.ovd.AndRdpActivity.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    AudioManager audioManager;//w w w  .  j  ava  2s .  c  o  m

    if (Config.DEBUG)
        Log.i(Config.TAG, "AndRdpActivity.dispatchKeyEvent " + event);

    // Disable keypress if it is from a mouse or touchpad.
    if (event.getDeviceId() >= 0) {
        InputDevice dev = InputDevice.getDevice(event.getDeviceId());
        if (dev.getSources() == InputDevice.SOURCE_MOUSE || dev.getSources() == InputDevice.SOURCE_TOUCHPAD)
            return true;
    }

    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_MENU:
            OnThreeFingers(null);
            return true;
        case KeyEvent.KEYCODE_BACK:
            Log.i(Config.TAG, "Back key pressed");
            askLogoutDialog();
            return true;
        case KeyEvent.KEYCODE_VOLUME_UP:
            audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
            audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE,
                    AudioManager.FLAG_SHOW_UI);
            return true;
        case KeyEvent.KEYCODE_VOLUME_DOWN:
            audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
            audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER,
                    AudioManager.FLAG_SHOW_UI);
            return true;
        }
    } else if (event.getAction() == KeyEvent.ACTION_UP) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_MENU:
        case KeyEvent.KEYCODE_BACK:
        case KeyEvent.KEYCODE_VOLUME_UP:
        case KeyEvent.KEYCODE_VOLUME_DOWN:
            return true;
        }
    }

    if (isLoggedIn() && rdp.dispatchKeyEvent(event))
        return true;

    return super.dispatchKeyEvent(event);
}

From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.AppsViewFragment.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP) {
        if (!event.isTracking()) {
            return true;
        }/*from   ww w  .ja v  a 2 s. c  o  m*/
        if (!event.isLongPress()) {
            AudioManager audio = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);
            audio.adjustVolume(AudioManager.ADJUST_RAISE,
                    AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI);
            return true;
        }
    }
    if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN) {
        if (!event.isTracking()) {
            return true;
        }
        if (!event.isLongPress()) {
            AudioManager audio = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);
            audio.adjustVolume(AudioManager.ADJUST_LOWER,
                    AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI);
            return true;
        }
    }
    return false;
}

From source file:edu.sfsu.csc780.chathub.ui.activities.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    DesignUtils.applyColorfulTheme(this);
    setContentView(R.layout.activity_main);
    mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    // Set default username is anonymous.
    mUsername = ANONYMOUS;/*from ww  w . j  a va2  s . c o  m*/
    //Initialize Auth
    mAuth = FirebaseAuth.getInstance();
    mUser = mAuth.getCurrentUser();
    if (mUser == null) {
        startActivity(new Intent(this, SignInActivity.class));
        finish();
        return;
    } else {
        mUsername = mUser.getDisplayName();
        if (mUser.getPhotoUrl() != null) {
            mPhotoUrl = mUser.getPhotoUrl().toString();
        }
    }

    AudioUtil.startAudioListener(this);

    mSinchClient = Sinch.getSinchClientBuilder().context(getApplicationContext())
            .applicationKey(APIKeys.SINCH_API_KEY).applicationSecret(APIKeys.SINCH_APP_SECRET)
            .environmentHost("sandbox.sinch.com")
            .userId(UserUtil.parseUsername(mSharedPreferences.getString("username", "anonymous"))).build();
    mSinchClient.setSupportCalling(true);

    mCurrentChannel = mSharedPreferences.getString("currentChannel", "general");
    mCurrChanTextView = (TextView) findViewById(R.id.currentChannelName);
    mCurrChanTextView.setText(ChannelUtil.getChannelDisplayName(mCurrentChannel, this));

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
            .addApi(Auth.GOOGLE_SIGN_IN_API).build();

    // Initialize ProgressBar and RecyclerView.

    mMessageRecyclerView = (RecyclerView) findViewById(R.id.messageRecyclerView);
    mLinearLayoutManager = new LinearLayoutManager(this);
    mLinearLayoutManager.setStackFromEnd(true);
    mMessageRecyclerView.setLayoutManager(mLinearLayoutManager);
    mChannelAdd = (RelativeLayout) findViewById(R.id.channelAdd);

    mToolBar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolBar);
    mToolBar.setTitleTextColor(Color.WHITE);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
    mDrawerLayout.setStatusBarBackgroundColor(ContextCompat.getColor(this, R.color.colorPrimary));

    mFirebaseAdapter = MessageUtil.getFirebaseAdapter(this, this, /* MessageLoadListener */
            mLinearLayoutManager, mMessageRecyclerView, mImageClickListener);
    mMessageRecyclerView.setAdapter(mFirebaseAdapter);

    mProgressBar.setVisibility(ProgressBar.INVISIBLE);

    mMessageEditText = (EditText) findViewById(R.id.messageEditText);
    mMessageEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(MSG_LENGTH_LIMIT) });
    mMessageEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            if (charSequence.toString().trim().length() > 0) {
                mSendButton.setEnabled(true);
            } else {
                mSendButton.setEnabled(false);
            }
        }

        @Override
        public void afterTextChanged(Editable editable) {
        }
    });

    mSendButton = (FloatingActionButton) findViewById(R.id.sendButton);
    mSendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // Send messages on click.
            mMessageRecyclerView.scrollToPosition(0);
            ChatMessage chatMessage = new ChatMessage(mMessageEditText.getText().toString(), mUsername,
                    mPhotoUrl, mCurrentChannel);
            MessageUtil.send(chatMessage, MainActivity.this);
            mMessageEditText.setText("");
        }
    });

    mImageButton = (ImageButton) findViewById(R.id.shareImageButton);
    mImageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            pickImage();
        }
    });

    mPhotoButton = (ImageButton) findViewById(R.id.cameraButton);
    mPhotoButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dispatchTakePhotoIntent();
        }
    });

    mLocationButton = (ImageButton) findViewById(R.id.locationButton);
    mLocationButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            loadMap();
        }
    });

    mChannelAdd.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(MainActivity.this, ChannelSearchActivity.class);
            startActivityForResult(intent, REQUEST_NEW_CHANNEL);
        }
    });

    SearchView jumpSearchView = (SearchView) findViewById(R.id.jumpSearch);
    int id = jumpSearchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
    TextView textView = (TextView) jumpSearchView.findViewById(id);
    textView.setTextColor(Color.WHITE);
    textView.setHintTextColor(Color.WHITE);

    jumpSearchView.setIconified(false);
    jumpSearchView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Toast.makeText(MainActivity.this, "Not implemented", Toast.LENGTH_SHORT).show();
        }
    });

    mNavRecyclerView = (RecyclerView) findViewById(R.id.navRecyclerView);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    mNavRecyclerView.setLayoutManager(linearLayoutManager);
    mNavRecyclerView.setAdapter(ChannelUtil.getFirebaseAdapterForUserChannelList(mChannelClickListener,
            mAuth.getCurrentUser().getDisplayName()));

    RecyclerView userListRecyclerView = (RecyclerView) findViewById(R.id.userListRecyclerView);
    LinearLayoutManager linearLayoutManager2 = new LinearLayoutManager(this);
    userListRecyclerView.setLayoutManager(linearLayoutManager2);
    userListRecyclerView.setAdapter(UserUtil.getFirebaseAdapterForUserList(mChannelClickListener));

    Button voiceCallButton = (Button) findViewById(R.id.voiceCall);
    mCallProgressTextView = (TextView) findViewById(R.id.callinprogress);

    final AudioManager audioManager = (AudioManager) getApplicationContext()
            .getSystemService(Context.AUDIO_SERVICE);
    voiceCallButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            CallClient callClient = mSinchClient.getCallClient();
            if (canCall) {
                call = callClient.callConference("General");
                call.addCallListener(new CallListener() {
                    @Override
                    public void onCallProgressing(Call call) {
                        //setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
                        audioManager.adjustStreamVolume(AudioManager.STREAM_VOICE_CALL,
                                AudioManager.ADJUST_RAISE, 10);
                        Log.d("Call", "Call progressing");
                    }

                    @Override
                    public void onCallEstablished(Call call) {
                        setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
                        mCallProgressTextView.setVisibility(View.VISIBLE);
                        Log.d("Call", "Calling now");
                    }

                    @Override
                    public void onCallEnded(Call call) {
                        setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE);
                        Log.d("Call", "Stopped calling");
                        mCallProgressTextView.setVisibility(View.INVISIBLE);
                    }

                    @Override
                    public void onShouldSendPushNotification(Call call, List<PushPair> list) {
                        Log.d("Call", "Push");
                    }
                });
            }
        }
    });

    Button endCallButton = (Button) findViewById(R.id.endCall);
    endCallButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (call != null) {
                call.hangup();
                call = null;
            }
        }
    });
}

From source file:com.smc.tw.waltz.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (DEBUG)/*from www  .  j  a  v a 2s  .c  om*/
        Log.d(TAG, "onKeyDown code:" + keyCode);

    switch (keyCode) {
    case KeyEvent.KEYCODE_VOLUME_UP: {
        mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE,
                AudioManager.FLAG_SHOW_UI);

        return true;
    }

    case KeyEvent.KEYCODE_VOLUME_DOWN: {
        mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER,
                AudioManager.FLAG_SHOW_UI);

        return true;
    }

    default:
        break;
    }

    return super.onKeyDown(keyCode, event);
}

From source file:com.csipsimple.ui.incall.CallActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    Log.d(TAG, "Key down : " + keyCode);
    switch (keyCode) {
    case KeyEvent.KEYCODE_VOLUME_DOWN:
    case KeyEvent.KEYCODE_VOLUME_UP:
        ///*ww w  . j  ava2 s  .  c o m*/
        // Volume has been adjusted by the user.
        //
        Log.d(TAG, "onKeyDown: Volume button pressed");
        int action = AudioManager.ADJUST_RAISE;
        if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
            action = AudioManager.ADJUST_LOWER;
        }

        // Detect if ringing
        SipCallSession currentCallInfo = getActiveCallInfo();
        // If not any active call active
        if (currentCallInfo == null && serviceConnected) {
            break;
        }

        //TODO: adjust volume here
        if (service != null) {
            try {
                service.adjustVolume(currentCallInfo, action, AudioManager.FLAG_SHOW_UI);
            } catch (RemoteException e) {
                Log.e(TAG, "Can't adjust volume", e);
            }
        }

        return true;
    case KeyEvent.KEYCODE_CALL:
    case KeyEvent.KEYCODE_ENDCALL:
        return inCallAnswerControls.onKeyDown(keyCode, event);
    case KeyEvent.KEYCODE_SEARCH:
        // Prevent search
        return true;
    default:
        // Nothing to do
    }
    return super.onKeyDown(keyCode, event);
}

From source file:github.daneren2005.dsub.service.DownloadService.java

public void updateRemoteVolume(boolean up) {
    AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    audioManager.adjustVolume(up ? AudioManager.ADJUST_RAISE : AudioManager.ADJUST_LOWER,
            AudioManager.FLAG_SHOW_UI);/*from   w  w w. j a v a  2 s.  c om*/
}

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  va 2s .  c om*/
            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;

}