Skip to content

Commit

Permalink
Merge pull request #53 from edugis-repo/51-eventkeycode-is-deprecated
Browse files Browse the repository at this point in the history
Changed event.keyCode to event.key or event.code
  • Loading branch information
anneb authored Jan 3, 2025
2 parents db3c2a5 + 6a0bb74 commit 2092d53
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/components/base/base-arrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ class BaseArrow extends LitElement {
}
_click(event) {
if (event instanceof KeyboardEvent) {
if (event.keyCode === 38) {
if (event.key === 'ArrowUp') {
/* up arrow key */
this.open = false;
event.stopPropagation();
return;
}
if (event.keyCode === 40) {
if (event.key === 'ArrowDown') {
/* down arrow key */
this.open = true;
event.stopPropagation();
return;
}
if (event.keyCode !== 32 && event.keyCode !== 13) {
if (event.code !== 'Space' && event.key !== 'Enter') {
return;
}
}
Expand Down
11 changes: 6 additions & 5 deletions src/components/map-draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,22 +621,23 @@ class MapDraw extends LitElement {
_keyDown(event) {
if (!((event.srcElement || event.target).classList.contains('mapboxgl-canvas') ||
(event.srcElement || event.target).classList.contains('maplibregl-canvas'))) return; // we only handle events on the map
if ((event.keyCode === 8 || event.keyCode === 46)) {
if ((event.key === 'Backspace' || event.key === 'Delete')) {
this.mbDraw.trash();
event.preventDefault();
} else if (event.keyCode === 49) {
} else if (event.key === '1') {
this._changeMode('draw_point');
} else if (event.keyCode === 50) {
} else if (event.key === '2') {
this._changeMode('draw_line_string');
} else if (event.keyCode === 51) {
} else if (event.key === '3') {
this._changeMode('draw_polygon');
} else if (event.keyCode === 27) {
} else if (event.key === 'Escape') {
this._setMode('simple_select');
} else if (event.key === 'z' && event.ctrlKey) {
this._undo();
} else if (event.key === 'y' && event.ctrlKey) {
this._redo();
}
console.log(event.key)
}
_isEmptyNewLayer(layer) {
return layer.isnewlayer;
Expand Down
2 changes: 1 addition & 1 deletion src/components/map-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ import { ifDefined } from "lit/directives/if-defined.js";
}

keyup(e) {
if (e.keyCode == 13) {
if (e.key == 'Enter') {
this.search(e);
} else {
this.resultList = null;
Expand Down

0 comments on commit 2092d53

Please sign in to comment.