7
7
* found in the LICENSE file at https://github.com/dalelotts/angular-bootstrap-datetimepicker/blob/master/LICENSE
8
8
*/
9
9
10
- export const ENTER = 13 ;
11
- export const SPACE = 32 ;
12
- export const PAGE_UP = 33 ;
13
- export const PAGE_DOWN = 34 ;
14
- export const END = 35 ;
15
- export const HOME = 36 ;
16
- export const UP_ARROW = 38 ;
17
- export const DOWN_ARROW = 40 ;
18
- export const RIGHT_ARROW = 39 ;
19
- export const LEFT_ARROW = 37 ;
10
+ export const ENTER = 'Enter' ;
11
+ export const SPACE = ' ' ;
12
+ export const PAGE_UP = 'PageUp' ;
13
+ export const PAGE_DOWN = 'PageDown' ;
14
+ export const END = 'End' ;
15
+ export const HOME = 'Home' ;
16
+ export const UP_ARROW = 'ArrowUp' ;
17
+ export const DOWN_ARROW = 'ArrowDown' ;
18
+ export const RIGHT_ARROW = 'ArrowRight' ;
19
+ export const LEFT_ARROW = 'ArrowLeft' ;
20
20
21
21
/** Utility to dispatch any event on a Node. */
22
22
export function dispatchEvent ( node : Node | Window , event : Event ) : Event {
@@ -25,30 +25,30 @@ export function dispatchEvent(node: Node | Window, event: Event): Event {
25
25
}
26
26
27
27
/** Shorthand to dispatch a keyboard event with a specified key code. */
28
- export function dispatchKeyboardEvent ( node : Node , type : string , keyCode : number , key ? : string , target ?: Element ) : KeyboardEvent {
29
- return dispatchEvent ( node , createKeyboardEvent ( type , keyCode , target , key ) ) as KeyboardEvent ;
28
+ export function dispatchKeyboardEvent ( node : Node , type : string , key : string , target ?: Element ) : KeyboardEvent {
29
+ return dispatchEvent ( node , createKeyboardEvent ( type , key , target ) ) as KeyboardEvent ;
30
30
}
31
31
32
32
/** Dispatches a keydown event from an element. */
33
- export function createKeyboardEvent ( type : string , keyCode : number , target ?: Element , key ?: string ) {
33
+ export function createKeyboardEvent ( type : string , key : string , target ?: Element ) {
34
34
const event = new KeyboardEvent ( type , {
35
35
bubbles : true ,
36
36
key : key ,
37
- code : keyCode . toString ( 10 ) ,
37
+ code : key ,
38
38
cancelable : true ,
39
39
} ) ;
40
40
41
41
// // Firefox does not support `initKeyboardEvent`, but supports `initKeyEvent`.
42
42
// const initEventFn = (event.initKeyEvent || event.initKeyboardEvent).bind(event);
43
43
const originalPreventDefault = event . preventDefault ;
44
44
45
- // Webkit Browsers don't set the keyCode when calling the init function.
46
- // See related bug https://bugs.webkit.org/show_bug.cgi?id=16735
47
- Object . defineProperties ( event , {
48
- keyCode : { get : ( ) => keyCode } ,
49
- key : { get : ( ) => key } ,
50
- target : { get : ( ) => target }
51
- } ) ;
45
+ // // Webkit Browsers don't set the keyCode when calling the init function.
46
+ // // See related bug https://bugs.webkit.org/show_bug.cgi?id=16735
47
+ // Object.defineProperties(event, {
48
+ // keyCode: {get: () => keyCode},
49
+ // key: {get: () => key},
50
+ // target: {get: () => target}
51
+ // });
52
52
53
53
// IE won't set `defaultPrevented` on synthetic events so we need to do it manually.
54
54
event . preventDefault = function ( ) {
0 commit comments