Skip to content

Instantly share code, notes, and snippets.

View i-am-henri's full-sized avatar
🎮
Making the Internet better ⚡️

henri i-am-henri

🎮
Making the Internet better ⚡️
View GitHub Profile
@KristofferEriksson
KristofferEriksson / useKeypress.ts
Last active July 20, 2024 08:35
A React custom hook for handling keyboard events.
import { useEffect } from "react";
const Keys = {
Backspace: "Backspace",
Tab: "Tab",
Enter: "Enter",
Shift: "Shift",
Control: "Control",
Alt: "Alt",
Pause: "Pause",
@KristofferEriksson
KristofferEriksson / useShare.ts
Created February 7, 2024 22:19
A React Typescript hook that let users share your content directly via native share dialogs
import { useCallback, useEffect, useState } from "react";
// Types for the useShare hook parameters
interface UseShareParams {
onShare?: (content: ShareParams) => void;
onSuccess?: (content: ShareParams) => void;
onError?: (error: any) => void;
fallback?: () => void;
successTimeout?: number;
}