AylaKeyCodePractice

About This Space

Test KeyCodes and pui.fieldExit() routine.


Last updated on October 19, 2021

Forked from: /scottklement/keycode/

Public Permissions:   View   Open/Fork   Run   Comment  

KeyCode Test

This is meant as a simple way to test the keyCode values produced on various devices. Since this is a publicly available site, you can easily send the link to customers for them to try it, and you can easily open it from your mobile devices (even if using a cell phone network.)

The output below the text boxes shows the keyCode and whether the shift key was pressed. So 107 false indicates that it was keyCode 107, and the shift key was not pressed. Whereas 187 true indicates that keyCode 187 was pressed, and the shift key was pressed.

Also the screen-level onkeydown event is set to the following:

if (pui.touchDevice && event.keyCode==187 && event.shiftKey==true) {
  pui.fieldExit(false);
  preventEvent(event);
}
else if (!pui.touchDevice && event.keyCode==107) {
  pui.fieldExit(false);
  preventEvent(event);
}

The pui.fieldExit function is being called on a touch device if keyCode 187 (which is the = key on the row of keys at the top of the keyboard) was pressed and the shift key was held down. We must use pui.fieldExit() for this instead of pui["field exit key"] because the latter does not allow shifted keys.

On a non-touch device, it looks for keyCode 107 (the + key on the numeric keypad at the side). In this case it would be possible to use pui["field exit key"] = 107; to do the same thing -- but, this method is a bit more flexible since we can write expressions to check for stuff like touch devices, shift keys, etc. So we may as well keep using it here, too.

Be the first to comment:      

Comments

Write Preview Markdown: bold italic code link
Post

More Spaces By Ayla (@ayla)

Filters:

Popular Recent

playing around!

3052

0

0

Low-code Node.js

3402

0

0

KeyCode

2859

0

0

Test KeyCodes and pui.fieldExit() routine.

2867

0

0

test

3003

0

0

Rich Display application

2519

0

0

Rich Display application

2252

0

0

Simple calendar app for entering daily info.

3015

0

0

test

2633

0

0

test

2536

0

0

ex

test

2458

0

0

Glen's email example

2294

0

0