TanStack

createFormatter

ts
function createFormatter<TFormat>(
   format, 
   getPlatform, 
   getLayoutMap
): TFormat;

Defined in: adapter.ts:667

Returns format, such as formatForDisplay or formatForAria, with a provider's platform and keyboard layout used when the call doesn't pass them. Only a hotkey that names a physical key reads getLayoutMap, so other hotkeys don't depend on the layout.

Type Parameters

TFormat

TFormat extends (hotkey, options?) => unknown

Parameters

format

TFormat

getPlatform

() => HotkeyPlatform | undefined

getLayoutMap

() => KeyboardLayoutMap | null | undefined

Returns

TFormat

Example

ts
const format = createFormatter(formatForAria, () => provider.platform, () => layoutMap)