title: Turn on/off caps lock and shift key programatically on android
body: <p>I am developing an android application (keyboard driver) in which first I am connecting Bluetooth keyboard  with android device , after successful connection in my Inputmethod service I am receiving key presses and send it to currently open editor. The problem is that I am unable to figure out how to turn on/off caps lock and shift key functionality in android. </p>
  
  <p>Any help !! </p>
  
  <p>This is the  broadcast receiver which is receiving keys from Bluetooth keyboard</p>
  
  <pre><code>private BroadcastReceiver key3Receiver = new BroadcastReceiver() {
  
      @Override
      public void onReceive(Context context, Intent intent) {
          int key = Integer.parseInt(intent
                  .getStringExtra(BluezService.COLONY_KEYPRESS_KEY));
          int action = intent.getIntExtra(BluezService.EVENT_KEYPRESS_ACTION,
                  KeyEvent.ACTION_DOWN);
          Log.d("++++ key recieved   ", Integer.toString(key));
  
          InputConnection ic = getCurrentInputConnection();
          long eventTime = SystemClock.uptimeMillis();
  
          // ********* Hacks
          if(key==8)
          {
              key=127;
          }
  
  
          if (key &lt; 130) {                
              ic.sendKeyEvent(new KeyEvent(eventTime, eventTime, action,COLONYKEYCODE[key],
                      0, COLONYKEYCODE[key], 0, 0, KeyEvent.FLAG_SOFT_KEYBOARD));
          }
  
      }
  };
  </code></pre>