How to use getKeysymSpecial method in redwood

Best JavaScript code snippet using redwood

broadway.js

Source:broadway.js Github

copy

Full Screen

...390 // everything in keydown that we have all info for, and that391 // are not safe to pass on to the browser (as it may do something392 // with the key. The rest we pass on to keypress so we can get the393 // translated keysym.394 function getKeysymSpecial(ev) {395 if (ev.keyCode in specialKeyTable) {396 var r = specialKeyTable[ev.keyCode];397 var flags = 0;398 if (typeof r !== 'number') {399 flags = r[1];400 r = r[0];401 }402 if (ev.type === 'keydown' || flags & ON_KEYDOWN) {403 return r;404 }405 }406 // If we don't hold alt or ctrl, then we should be safe to pass407 // on to keypressed and look at the translated data408 if (!ev.ctrlKey && !ev.altKey) {409 return null;410 }411 var keysym = getEventKeySym(ev);412 // Remap symbols413 switch (keysym) {414 case 186 : keysym = 59; break; // ; (IE)415 case 187 : keysym = 61; break; // = (IE)416 case 188 : keysym = 44; break; // , (Mozilla, IE)417 case 109 : // - (Mozilla, Opera)418 if (true) {419 // TODO: check if browser is firefox or opera420 keysym = 45;421 }422 break;423 case 189 : keysym = 45; break; // - (IE)424 case 190 : keysym = 46; break; // . (Mozilla, IE)425 case 191 : keysym = 47; break; // / (Mozilla, IE)426 case 192 : keysym = 96; break; // ` (Mozilla, IE)427 case 219 : keysym = 91; break; // [ (Mozilla, IE)428 case 220 : keysym = 92; break; // \ (Mozilla, IE)429 case 221 : keysym = 93; break; // ] (Mozilla, IE)430 case 222 : keysym = 39; break; // ' (Mozilla, IE)431 }432 // Remap shifted and unshifted keys433 if (!!ev.shiftKey) {434 switch (keysym) {435 case 48 : keysym = 41 ; break; // ) (shifted 0)436 case 49 : keysym = 33 ; break; // ! (shifted 1)437 case 50 : keysym = 64 ; break; // @ (shifted 2)438 case 51 : keysym = 35 ; break; // # (shifted 3)439 case 52 : keysym = 36 ; break; // $ (shifted 4)440 case 53 : keysym = 37 ; break; // % (shifted 5)441 case 54 : keysym = 94 ; break; // ^ (shifted 6)442 case 55 : keysym = 38 ; break; // & (shifted 7)443 case 56 : keysym = 42 ; break; // * (shifted 8)444 case 57 : keysym = 40 ; break; // ( (shifted 9)445 case 59 : keysym = 58 ; break; // : (shifted `)446 case 61 : keysym = 43 ; break; // + (shifted ;)447 case 44 : keysym = 60 ; break; // < (shifted ,)448 case 45 : keysym = 95 ; break; // _ (shifted -)449 case 46 : keysym = 62 ; break; // > (shifted .)450 case 47 : keysym = 63 ; break; // ? (shifted /)451 case 96 : keysym = 126; break; // ~ (shifted `)452 case 91 : keysym = 123; break; // { (shifted [)453 case 92 : keysym = 124; break; // | (shifted \)454 case 93 : keysym = 125; break; // } (shifted ])455 case 39 : keysym = 34 ; break; // " (shifted ')456 }457 } else if ((keysym >= 65) && (keysym <= 90)) {458 // Remap unshifted A-Z459 keysym += 32;460 } else if (ev.keyLocation === 3) {461 // numpad keys462 switch (keysym) {463 case 96 : keysym = 48; break; // 0464 case 97 : keysym = 49; break; // 1465 case 98 : keysym = 50; break; // 2466 case 99 : keysym = 51; break; // 3467 case 100: keysym = 52; break; // 4468 case 101: keysym = 53; break; // 5469 case 102: keysym = 54; break; // 6470 case 103: keysym = 55; break; // 7471 case 104: keysym = 56; break; // 8472 case 105: keysym = 57; break; // 9473 case 109: keysym = 45; break; // -474 case 110: keysym = 46; break; // .475 case 111: keysym = 47; break; // /476 }477 }478 return keysym;479 }480 function getKeyEvent(keyCode, pop) {481 var i, fev = null;482 for (i = keyDownList.length - 1; i >= 0; i--) {483 if (keyDownList[i].keyCode === keyCode) {484 if ((typeof pop !== 'undefined') && pop) {485 fev = keyDownList.splice(i, 1)[0];486 } else {487 fev = keyDownList[i];488 }489 break;490 }491 }492 return fev;493 }494 /////////////////////////////////////////////////////////////////////////////495 // COMMANDS496 /////////////////////////////////////////////////////////////////////////////497 function cmdGrabPointer(id, ownerEvents) {498 sendInput('g', []);499 }500 function cmdUngrabPointer() {501 sendInput('u', []);502 }503 function cmdPutBuffer(id, w, h, compressed) {504 var surface = surfaces[id];505 var context = surface.canvas.getContext('2d');506 var inflate = new window.Zlib.RawInflate(compressed);507 var data = inflate.decompress();508 var imageData = decodeBuffer(context, surface.imageData, w, h, data, false);509 context.putImageData(imageData, 0, 0);510 surface.imageData = imageData;511 }512 function sendConfigureNotify(surface) {513 sendInput('w', [surface.id, surface.x, surface.y, surface.width, surface.height]);514 }515 function cmdLowerSurface(id) {516 /* TODO517 var surface = surfaces[id];518 */519 }520 function cmdRaiseSurface(id) {521 /* TODO522 var surface = surfaces[id];523 */524 }525 function cmdMoveResizeSurface(id, has_pos, x, y, has_size, w, h) {526 var surface = surfaces[id];527 console.debug('Broadway', 'onMoveResizeSurface()', [id, has_pos, has_size], [x, y], [w, h], surface);528 if ( has_pos ) {529 surface.positioned = true;530 surface.x = x;531 surface.y = y;532 }533 if ( has_size ) {534 surface.width = w;535 surface.height = h;536 }537 if ( has_size ) {538 resizeCanvas(surface.canvas, w, h);539 }540 if ( surface.isTemp ) {541 if ( has_pos ) {542 var parentSurface = surfaces[surface.transientParent];543 var xOffset = surface.x - parentSurface.x;544 var yOffset = surface.y - parentSurface.y;545 surface.xOff = xOffset;546 surface.yOff = yOffset;547 surface.canvas.style.left = xOffset + 'px';548 surface.canvas.style.top = yOffset + 'px';549 }550 } else {551 if ( surface.visible ) {552 OSjs.Broadway.Events.onMoveSurface(id, has_pos, has_size, surface);553 }554 }555 sendConfigureNotify(surface);556 }557 function cmdDeleteSurface(id) {558 var surface = surfaces[id];559 if ( surface ) {560 console.debug('Broadway', 'onDeleteSurface()', id);561 if ( surface.canvas.parentNode ) {562 surface.canvas.parentNode.removeChild(surface.canvas);563 }564 OSjs.Broadway.Events.onDeleteSurface(id);565 delete surfaces[id];566 }567 }568 function cmdSetTransientFor(id, parentId) {569 var surface = surfaces[id];570 if ( surface ) {571 if ( surface.transientParent === parentId ) {572 return;573 }574 surface.transientParent = parentId;575 var parentSurface = surfaces[parentId];576 if ( surface.positioned ) {577 console.debug('Broadway', 'onSetTransient()', id, parentId, surface);578 parentSurface.canvas.parentNode.appendChild(surface.canvas);579 }580 }581 }582 function cmdHideSurface(id) {583 var surface = surfaces[id];584 if ( surface ) {585 surface.visible = false;586 if ( surface.canvas ) {587 surface.canvas.style.display = 'none';588 }589 console.debug('Broadway', 'onHideSurface()', id);590 OSjs.Broadway.Events.onHideSurface(id);591 }592 }593 function cmdShowSurface(id) {594 var surface = surfaces[id];595 if ( surface ) {596 surface.visible = true;597 if ( surface.canvas ) {598 surface.canvas.style.display = 'inline';599 }600 console.debug('Broadway', 'onShowSurface()', id);601 OSjs.Broadway.Events.onShowSurface(id);602 }603 }604 function cmdCreateSurface(id, x, y, width, height, isTemp) {605 var surface = {606 id: id,607 xOff: 0,608 yOff: 0,609 x: x,610 y: y,611 width: width,612 height: height,613 isTemp: isTemp,614 positioned: isTemp,615 transientParent: 0,616 visible: false,617 imageData: null,618 canvas: document.createElement('canvas')619 };620 console.debug('Broadway', 'onCreateSurface()', surface);621 surface.canvas.width = width;622 surface.canvas.height = height;623 surface.canvas.setAttribute('data-surface-id', String(id));624 if ( isTemp ) {625 surface.canvas.style.position = 'absolute';626 surface.canvas.style.left = x + 'px';627 surface.canvas.style.top = y + 'px';628 surface.canvas.style.zIndex = '9999999';629 surface.canvas.style.display = 'none';630 }631 OSjs.Broadway.Events.onCreateSurface(id, surface);632 surfaces[id] = surface;633 sendConfigureNotify(surface);634 }635 /////////////////////////////////////////////////////////////////////////////636 // COMMAND HANDLERS637 /////////////////////////////////////////////////////////////////////////////638 var Commands = {639 D: function() {640 OSjs.Broadway.GTK.disconnect();641 },642 s: function(cmd) { // Create new surface643 cmdCreateSurface(644 cmd.get_16(), // id645 cmd.get_16s(), // x646 cmd.get_16s(), // y647 cmd.get_16(), // w648 cmd.get_16(), // h649 cmd.get_bool() // tmp650 );651 },652 S: function(cmd) { // Shows a surface653 cmdShowSurface(cmd.get_16());654 },655 H: function(cmd) { // Hides a surface656 cmdHideSurface(cmd.get_16());657 },658 p: function(cmd) { // Set transient parent659 cmdSetTransientFor(cmd.get_16(), cmd.get_16());660 },661 d: function(cmd) { // Deletes a surface662 cmdDeleteSurface(cmd.get_16());663 },664 m: function(cmd) { // Moves a surface665 var x, y, w, h;666 var id = cmd.get_16();667 var ops = cmd.get_flags();668 var has_pos = ops & 1;669 if ( has_pos ) {670 x = cmd.get_16s();671 y = cmd.get_16s();672 }673 var has_size = ops & 2;674 if ( has_size ) {675 w = cmd.get_16();676 h = cmd.get_16();677 }678 cmdMoveResizeSurface(id, has_pos, x, y, has_size, w, h);679 },680 r: function(cmd) { // Raises a surface681 cmdRaiseSurface(cmd.get_16());682 },683 R: function(cmd) { // Lowers a surface684 cmdLowerSurface(cmd.get_16());685 },686 b: function(cmd) { // Put image buffer687 cmdPutBuffer(688 cmd.get_16(), // id689 cmd.get_16(), // w690 cmd.get_16(), // h691 cmd.get_data() // data692 );693 },694 g: function(cmd) { // Grab695 cmdGrabPointer(cmd.get_16(), cmd.get_bool());696 },697 u: function() { // Ungrab698 cmdUngrabPointer();699 }700 };701 /////////////////////////////////////////////////////////////////////////////702 // INPUT INJECTORS703 /////////////////////////////////////////////////////////////////////////////704 var Input = {705 mousewheel: function(id, cid, ev, relx, rely, mx, my) {706 var offset = ev.detail ? ev.detail : -ev.wheelDelta;707 var dir = offset > 0 ? 1 : 0;708 sendInput('s', [id, cid, relx, rely, mx, my, lastState, dir]);709 },710 mousedown: function(id, cid, ev, relx, rely, mx, my) {711 updateForEvent(ev);712 var button = ev.button + 1;713 lastState = lastState | getButtonMask(button);714 sendInput('b', [id, cid, relx, rely, mx, my, lastState, button]);715 },716 mouseup: function(id, cid, ev, relx, rely, mx, my) {717 updateForEvent(ev);718 var button = ev.button + 1;719 lastState = lastState & ~getButtonMask(button);720 sendInput('B', [id, cid, relx, rely, mx, my, lastState, button]);721 },722 mouseover: function(id, cid, ev, relx, rely, mx, my) {723 updateForEvent(ev);724 if ( id !== 0 ) {725 sendInput('e', [id, cid, relx, rely, mx, my, lastState, GDK_CROSSING_NORMAL]);726 }727 },728 mouseout: function(id, cid, ev, relx, rely, mx, my) {729 updateForEvent(ev);730 if ( id !== 0 ) {731 sendInput('l', [id, cid, relx, rely, mx, my, lastState, GDK_CROSSING_NORMAL]);732 }733 },734 mousemove: function(id, cid, ev, relx, rely, mx, my) {735 updateForEvent(ev);736 sendInput('m', [id, cid, relx, rely, mx, my, lastState]);737 },738 keydown: function(id, cid, ev) {739 updateForEvent(ev);740 var fev = copyKeyEvent(ev || window.event);741 var keysym = getKeysymSpecial(ev);742 var suppress = false;743 fev.keysym = keysym;744 if ( keysym ) {745 if ( !ignoreKeyEvent(ev) ) {746 sendInput('k', [keysym, lastState]);747 }748 suppress = true;749 }750 if ( !ignoreKeyEvent(ev) ) {751 keyDownList.push(fev);752 }753 if ( suppress ) {754 cancelEvent(ev);755 }756 },757 keypress: function(id, cid, ev) {758 var kdlen = keyDownList.length;759 if (((typeof ev.which !== 'undefined') && (ev.which === 0)) || getKeysymSpecial(ev)) {760 // Firefox and Opera generate a keyPress event even if keyDown761 // is suppressed. But the keys we want to suppress will have762 // either:763 // - the which attribute set to 0764 // - getKeysymSpecial() will identify it765 cancelEvent(ev);766 return;767 }768 var keysym = getKeysym(ev);769 // Modify the which attribute in the depressed keys list so770 // that the keyUp event will be able to have the character code771 // translation available.772 if (kdlen > 0) {773 keyDownList[kdlen - 1].keysym = keysym;774 }775 // Send the translated keysym776 if (keysym > 0) {777 sendInput('k', [keysym, lastState]);778 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('redwood');2var keysym = redwood.getKeysymSpecial('F1');3console.log(keysym);4var redwood = require('redwood');5var keysym = redwood.getKeysymSpecial('F1');6console.log(keysym);7var redwood = require('redwood');8var keysym = redwood.getKeysymSpecial('F1');9console.log(keysym);10var redwood = require('redwood');11var keysym = redwood.getKeysymSpecial('F1');12console.log(keysym);13var redwood = require('redwood');14var keysym = redwood.getKeysymSpecial('F1');15console.log(keysym);16var redwood = require('redwood');17var keysym = redwood.getKeysymSpecial('F1');18console.log(keysym);19var redwood = require('redwood');20var keysym = redwood.getKeysymSpecial('F1');21console.log(keysym);22var redwood = require('redwood');23var keysym = redwood.getKeysymSpecial('F1');24console.log(keysym);25var redwood = require('redwood');26var keysym = redwood.getKeysymSpecial('F1');27console.log(keysym);28var redwood = require('redwood');29var keysym = redwood.getKeysymSpecial('F1');30console.log(keysym);31var redwood = require('redwood');32var keysym = redwood.getKeysymSpecial('F1');33console.log(keysym);

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('redwood');2var keysym = redwood.getKeysymSpecial('KEY_RIGHT');3console.log(keysym);4var redwood = require('redwood');5var keysym = redwood.getKeysymSpecial('KEY_RIGHT');6console.log(keysym);7var redwood = require('redwood');8var keysym = redwood.getKeysymSpecial('KEY_RIGHT');9console.log(keysym);10var redwood = require('redwood');11var keysym = redwood.getKeysymSpecial('KEY_RIGHT');12console.log(keysym);13var redwood = require('redwood');14var keysym = redwood.getKeysymSpecial('KEY_RIGHT');15console.log(keysym);16var redwood = require('redwood');17var keysym = redwood.getKeysymSpecial('KEY_RIGHT');18console.log(keysym);19var redwood = require('redwood');20var keysym = redwood.getKeysymSpecial('KEY_RIGHT');21console.log(keysym);22var redwood = require('redwood');23var keysym = redwood.getKeysymSpecial('KEY_RIGHT');24console.log(keysym);25var redwood = require('redwood');26var keysym = redwood.getKeysymSpecial('KEY_RIGHT');27console.log(keysym);28var redwood = require('redwood');29var keysym = redwood.getKeysymSpecial('KEY_RIGHT');30console.log(keysym);31var redwood = require('redwood');32var keysym = redwood.getKeysymSpecial('KEY_RIGHT');33console.log(keysym);

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('redwood');2var keysym = redwood.getKeysymSpecial(redwood.KEYSYM_SPECIAL_SHIFT);3console.log(keysym);4var redwood = require('redwood');5var keysym = redwood.getKeysymSpecial(redwood.KEYSYM_SPECIAL_CTRL);6console.log(keysym);7var redwood = require('redwood');8var keysym = redwood.getKeysymSpecial(redwood.KEYSYM_SPECIAL_ALT);9console.log(keysym);10var redwood = require('redwood');11var keysym = redwood.getKeysymSpecial(redwood.KEYSYM_SPECIAL_META);12console.log(keysym);13var redwood = require('redwood');14var keysym = redwood.getKeysymSpecial(redwood.KEYSYM_SPECIAL_CAPS_LOCK);15console.log(keysym);16var redwood = require('redwood');17var keysym = redwood.getKeysymSpecial(redwood.KEYSYM_SPECIAL_NUM_LOCK);18console.log(keysym);19var redwood = require('redwood');20var keysym = redwood.getKeysymSpecial(redwood.KEYSYM_SPECIAL_SCROLL_LOCK);21console.log(keysym);22var redwood = require('redwood');23var keysym = redwood.getKeysymSpecial(redwood.KEYSYM_SPECIAL_PRINT_SCREEN);24console.log(keysym);25var redwood = require('redwood');26var keysym = redwood.getKeysymSpecial(redwood.KEYSYM_SPECIAL_PAUSE);27console.log(keysym);

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('redwood');2var keysym = redwood.getKeysymSpecial('KEY_F1');3console.log('keysym for KEY_F1: ' + keysym);4var redwood = require('redwood');5var keysym = redwood.getKeysymSpecial('KEY_F2');6console.log('keysym for KEY_F2: ' + keysym);7var redwood = require('redwood');8var keysym = redwood.getKeysymSpecial('KEY_F3');9console.log('keysym for KEY_F3: ' + keysym);10var redwood = require('redwood');11var keysym = redwood.getKeysymSpecial('KEY_F4');12console.log('keysym for KEY_F4: ' + keysym);13var redwood = require('redwood');14var keysym = redwood.getKeysymSpecial('KEY_F5');15console.log('keysym for KEY_F5: ' + keysym);16var redwood = require('redwood');17var keysym = redwood.getKeysymSpecial('KEY_F6');18console.log('keysym for KEY_F6: ' + keysym);19var redwood = require('redwood');20var keysym = redwood.getKeysymSpecial('KEY_F7');21console.log('keysym for KEY_F7: ' + keysym);22var redwood = require('redwood');23var keysym = redwood.getKeysymSpecial('KEY_F8');24console.log('keysym for KEY_F8: ' + keysym);25var redwood = require('redwood');26var keysym = redwood.getKeysymSpecial('KEY_F9');27console.log('keysym for KEY_F9: ' + keysym);28var redwood = require('redwood');29var keysym = redwood.getKeysymSpecial('KEY_F10');30console.log('keysym for

Full Screen

Using AI Code Generation

copy

Full Screen

1var keyboard = require('redwood-keyboard');2var key = keyboard.getKeysymSpecial(keyboard.KEYSYM_KEY_LEFT);3console.log(key);4var keyboard = require('redwood-keyboard');5var key = keyboard.getKeysymNormal('a');6console.log(key);7var keyboard = require('redwood-keyboard');8var key = keyboard.getKeysym('a');9console.log(key);10var keyboard = require('redwood-keyboard');11var key = keyboard.getKeysymName(97);12console.log(key);13var keyboard = require('redwood-keyboard');14var key = keyboard.getKeysymFromName('a');15console.log(key);16var keyboard = require('redwood-keyboard');17var key = keyboard.isNormal(97);18console.log(key);19var keyboard = require('redwood-keyboard');20var key = keyboard.isSpecial(65361);21console.log(key);

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('redwood');2var keysym = redwood.getKeysymSpecial('ctrl');3console.log(keysym);4var redwood = require('redwood');5var keysym = redwood.getKeysymSpecial('shift');6console.log(keysym);7var redwood = require('redwood');8var keysym = redwood.getKeysymSpecial('alt');9console.log(keysym);10var redwood = require('redwood');11var keysym = redwood.getKeysymSpecial('backspace');12console.log(keysym);13var redwood = require('redwood');14var keysym = redwood.getKeysymSpecial('esc');15console.log(keysym);16var redwood = require('redwood');17var keysym = redwood.getKeysymSpecial('tab');18console.log(keysym);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run redwood automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful