feat: support 0-9 column selection

This commit is contained in:
Shusui MOYATANI
2023-03-09 01:30:57 +09:00
parent 817657c053
commit c6e3b04294
4 changed files with 43 additions and 10 deletions

View File

@@ -13,7 +13,8 @@ export type MoveToNextItem = CommandBase<'moveToNextItem'>;
export type MoveToPrevItem = CommandBase<'moveToPrevItem'>;
export type MoveToPrevColumn = CommandBase<'moveToPrevColumn'>;
export type MoveToNextColumn = CommandBase<'moveToNextColumn'>;
export type MoveToColumn = CommandBase<'moveToNextColumn'> & { columnIndex: number };
export type MoveToColumn = CommandBase<'moveToColumn'> & { columnIndex: number };
export type MoveToLastColumn = CommandBase<'moveToLastColumn'>;
export type Like = CommandBase<'like'>;
export type Repost = CommandBase<'repost'>;
export type OpenReplyForm = CommandBase<'openReplyForm'>;
@@ -28,6 +29,8 @@ export type Command =
| MoveToPrevItem
| MoveToPrevColumn
| MoveToNextColumn
| MoveToColumn
| MoveToLastColumn
| Like
| Repost
| OpenReplyForm

View File

@@ -14,6 +14,16 @@ const defaultShortcut: Shortcut[] = [
{ key: 'j', command: { command: 'moveToNextItem' } },
{ key: 'k', command: { command: 'moveToPrevItem' } },
{ key: 'l', command: { command: 'moveToNextColumn' } },
{ key: '1', command: { command: 'moveToColumn', columnIndex: 1 } },
{ key: '2', command: { command: 'moveToColumn', columnIndex: 2 } },
{ key: '3', command: { command: 'moveToColumn', columnIndex: 3 } },
{ key: '4', command: { command: 'moveToColumn', columnIndex: 4 } },
{ key: '5', command: { command: 'moveToColumn', columnIndex: 5 } },
{ key: '6', command: { command: 'moveToColumn', columnIndex: 6 } },
{ key: '7', command: { command: 'moveToColumn', columnIndex: 7 } },
{ key: '8', command: { command: 'moveToColumn', columnIndex: 8 } },
{ key: '9', command: { command: 'moveToColumn', columnIndex: 9 } },
{ key: '0', command: { command: 'moveToLastColumn' } },
{ key: 'ArrowLeft', command: { command: 'moveToPrevColumn' } },
{ key: 'ArrowDown', command: { command: 'moveToNextItem' } },
{ key: 'ArrowUp', command: { command: 'moveToPrevItem' } },
@@ -52,7 +62,7 @@ const useShortcutKeys = ({ shortcuts = defaultShortcut, onShortcut }: UseShortcu
if (shortcut == null) return;
onShortcut(shortcut);
}, 100);
}, 50);
window.addEventListener('keydown', handleKeydown);