DEV Community

Discussion on: Forem: Keyboard shortcuts

reobin profile image
Robin Gagnon

Once there is the navigation for the article feed, the bookmark shortcut is a must.

Throwing ideas below:

  • Write a new post (n?)
  • Go to profile (p?)
  • Go to listings (l?)
  • Go back to the feed (f?)
  • Maybe shortcuts to switch between the different feeds (week, month, etc.)
link2twenty profile image
Andrew Bone Author • Edited on

I like those maybe add message (M) too?

Twitter use chaining for certain actions like going to a certain page is g then another letter which is something we can theoretically do with the hook.

reobin profile image
Robin Gagnon

Chaining sound super nice! vim-like 🌞

Thread Thread
link2twenty profile image
Andrew Bone Author

If that's a road we wanna go down it might be worth including chaining in the hook currently the only way to do it would be something like.

const [chaining, setChaining] = useState([]);
const [chainingQueue, setChainingQueue] = useState([]);

const pushChaining = useCallback((item)=>{
  setChaining([...chaining, item]);

  let timeout;

  timeout = window.setTimeout(()=>{
  }, 1500);

  if(!chainingQueue) return;

  return ()=>clearTimeout(timeout);
},[chainingQueue, pushChaining]);

  KeyG: setChainingQueue('KeyG'),
  KeyH: (chaining === ['KeyG'] && function)
Enter fullscreen mode Exit fullscreen mode

Which is a bit convoluted to do over and over again.