Java Code Examples for android.view.KeyEvent#KEYCODE_PERIOD
The following examples show how to use
android.view.KeyEvent#KEYCODE_PERIOD .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MatrixKeypadTest.java From contrib-drivers with Apache License 2.0 | 6 votes |
/** * Tests that the callback will retrieve the expected values. * @throws IOException */ @Test public void testCallbackKeyDown() throws IOException { final int[] index = {0}; final int[] testKeys = new int[] {KeyEvent.KEYCODE_A, KeyEvent.KEYCODE_NUMPAD_1, KeyEvent.KEYCODE_PERIOD}; mMatrixKeypad = new MatrixKeypad(mRowPins, mColPins, mKeyCodes, PowerMockito.mock(Handler.class)); mMatrixKeypad.setKeyCallback(new OnKeyEventListener() { @Override public void onKeyEvent(MatrixKey matrixKey) { assertEquals(testKeys[index[0]++], matrixKey.getKeyCode()); assertTrue(matrixKey.isPressed()); } }); for (int key : testKeys) { mMatrixKeypad.keyDown(key); } }
Example 2
Source File: MatrixKeypadTest.java From contrib-drivers with Apache License 2.0 | 6 votes |
/** * Tests that the callback will retrieve the expected values. * @throws IOException */ @Test public void testCallbackKeyUp() throws IOException { final int[] index = {0}; final int[] testKeys = new int[] {KeyEvent.KEYCODE_A, KeyEvent.KEYCODE_NUMPAD_1, KeyEvent.KEYCODE_PERIOD}; mMatrixKeypad = new MatrixKeypad(mRowPins, mColPins, mKeyCodes, PowerMockito.mock(Handler.class)); mMatrixKeypad.setKeyCallback(new OnKeyEventListener() { @Override public void onKeyEvent(MatrixKey matrixKey) { assertEquals(testKeys[index[0]++], matrixKey.getKeyCode()); assertFalse(matrixKey.isPressed()); } }); for (int key : testKeys) { mMatrixKeypad.keyUp(key); } }
Example 3
Source File: ScanGunKeyEventHelper.java From scangon with Apache License 2.0 | 5 votes |
private char getInputCode(KeyEvent event) { int keyCode = event.getKeyCode(); char aChar; if (keyCode >= KeyEvent.KEYCODE_A && keyCode <= KeyEvent.KEYCODE_Z) { //字母 aChar = (char) ((mCaps ? 'A' : 'a') + keyCode - KeyEvent.KEYCODE_A); } else if (keyCode >= KeyEvent.KEYCODE_0 && keyCode <= KeyEvent.KEYCODE_9) { //数字 aChar = (char) ('0' + keyCode - KeyEvent.KEYCODE_0); } else { //其他符号 switch (keyCode) { case KeyEvent.KEYCODE_PERIOD: aChar = '.'; break; case KeyEvent.KEYCODE_MINUS: aChar = mCaps ? '_' : '-'; break; case KeyEvent.KEYCODE_SLASH: aChar = '/'; break; case KeyEvent.KEYCODE_BACKSLASH: aChar = mCaps ? '|' : '\\'; break; default: aChar = 0; break; } } return aChar; }