Skip to content

Commit

Permalink
Add option to enable/disable keyboard navigation
Browse files Browse the repository at this point in the history
For times when it may conflict with other keyboard bindings on a page
  • Loading branch information
fitztrev committed Dec 11, 2024
1 parent 12207f7 commit d9a293d
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm-lock.yaml
2 changes: 1 addition & 1 deletion demo/demo.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const defaults: Opts = {
showMoves: 'auto', // false | "right" | "bottom" | auto. "auto" uses media queries
showControls: true, // show the [prev, menu, next] buttons
scrollToMove: true, // enable scrolling through moves with a mouse wheel
keyboardToMove: true, // enable keyboard navigation through moves
orientation: undefined, // orientation of the board. Undefined to use the Orientation PGN tag.
initialPly: 0, // current position to display. Can be a number, or "last"
chessground: {}, // chessground configuration https://github.com/lichess-org/chessground/blob/master/src/config.ts#L7
Expand Down
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export interface Opts {
showControls: boolean;
initialPly: Ply | 'last';
scrollToMove: boolean;
keyboardToMove: boolean;
drawArrows: boolean;
menu: {
getPgn: {
Expand Down
2 changes: 1 addition & 1 deletion src/view/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function view(ctrl: PgnViewer) {
},
hook: onInsert(el => {
ctrl.setGround(Chessground(el.querySelector('.cg-wrap') as HTMLElement, makeConfig(ctrl, el)));
el.addEventListener('keydown', onKeyDown(ctrl));
if (opts.keyboardToMove) el.addEventListener('keydown', onKeyDown(ctrl));
}),
},
[
Expand Down

0 comments on commit d9a293d

Please sign in to comment.