mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[dom] keyCodes like in Firefox
KeyboardEvent.keyCode returns 0 in Firefox for test case. I won't change the test, because elinks relies on libdom API.
This commit is contained in:
parent
2b4dd0f7ba
commit
8a2e85b73f
@ -228,7 +228,6 @@ static const char *__keys_names[] = {
|
||||
"Insert",
|
||||
"Delete",
|
||||
"F1",
|
||||
"F1",
|
||||
"F2",
|
||||
"F3",
|
||||
"F4",
|
||||
@ -254,6 +253,7 @@ static enum {
|
||||
KEYB_HOME,
|
||||
KEYB_END,
|
||||
KEYB_ESCAPE,
|
||||
KEYB_BACKSPACE,
|
||||
KEYB_TAB,
|
||||
KEYB_INSERT,
|
||||
KEYB_DELETE,
|
||||
@ -338,30 +338,55 @@ convert_dom_string_to_keycode(dom_string *dom_key)
|
||||
case KEYB_ENTER:
|
||||
return 13;
|
||||
case KEYB_ARROW_LEFT:
|
||||
return 37;
|
||||
case KEYB_ARROW_RIGHT:
|
||||
return 39;
|
||||
case KEYB_ARROW_UP:
|
||||
return 38;
|
||||
case KEYB_ARROW_DOWN:
|
||||
return 40;
|
||||
case KEYB_PAGE_UP:
|
||||
return 33;
|
||||
case KEYB_PAGE_DOWN:
|
||||
return 34;
|
||||
case KEYB_HOME:
|
||||
return 36;
|
||||
case KEYB_END:
|
||||
return 35;
|
||||
case KEYB_ESCAPE:
|
||||
return 27;
|
||||
case KEYB_BACKSPACE:
|
||||
return 8;
|
||||
case KEYB_TAB:
|
||||
return 9;
|
||||
case KEYB_INSERT:
|
||||
return 45;
|
||||
case KEYB_DELETE:
|
||||
return 46;
|
||||
case KEYB_F1:
|
||||
return 112;
|
||||
case KEYB_F2:
|
||||
return 113;
|
||||
case KEYB_F3:
|
||||
return 114;
|
||||
case KEYB_F4:
|
||||
return 115;
|
||||
case KEYB_F5:
|
||||
return 116;
|
||||
case KEYB_F6:
|
||||
return 117;
|
||||
case KEYB_F7:
|
||||
return 118;
|
||||
case KEYB_F8:
|
||||
return 119;
|
||||
case KEYB_F9:
|
||||
return 120;
|
||||
case KEYB_F10:
|
||||
return 121;
|
||||
case KEYB_F11:
|
||||
return 122;
|
||||
case KEYB_F12:
|
||||
return 0;
|
||||
return 123;
|
||||
default:
|
||||
{
|
||||
char *utf8 = dom_string_data(dom_key);
|
||||
|
@ -1,13 +1,17 @@
|
||||
<script>
|
||||
var e = new KeyboardEvent('message', { cancelable: true, key: "Enter" });
|
||||
var e = new KeyboardEvent('keydown', { cancelable: true, key: "Enter" });
|
||||
|
||||
console.error('keyboardEvent.html');
|
||||
console.assert(e.cancelable, 'cancelable true');
|
||||
console.assert(!e.defaultPrevented, 'false');
|
||||
e.preventDefault();
|
||||
console.assert(e.defaultPrevented, 'true');
|
||||
console.assert(e.type === 'message', 'message');
|
||||
console.assert(e.type === 'keydown', 'keydown');
|
||||
console.assert(e.key === 'Enter', 'key Enter');
|
||||
console.assert(e.keyCode === 13, 'ENTER = 13');
|
||||
|
||||
var e = new KeyboardEvent('keydown', { cancelable: true, key: "F12" });
|
||||
console.assert(e.keyCode === 123, e.keyCode);
|
||||
|
||||
console.exit(0);
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user