Tag Archives: button

[React/버튼] button 태그로 만든 버튼이 아닌, div 태그로 a 태그(anchor)를 감싼 형태의 button에 대한 이벤트 바인딩 삽질기

By | 9월 23, 2022

환경 React 18.2.0 Typescript 4.6.3 eslint 8.16.0 common.ts /** * onKeyDown 이벤트핸들러에서 엔터키로 함수 실행하기 */ export const onKeyDownCall = (e: React.KeyboardEvent, func: (ev: React.SyntheticEvent) => void) => { // 'keypress' event misbehaves on mobile so we track 'Enter' key via 'keydown' event if (e.key === 'Enter') { e.preventDefault(); e.stopPropagation(); func(e); } }; test.tsx //… Read More »

[Android] 뒤로가기 버튼 두 번 눌렀을 때 앱 종료하기

By | 12월 29, 2020

인터넷에 널린 유사한 글들을 살짝 수정함.   * 뒤로가기 핸들러 정의 package and.bruce.com.handler; import android.app.Activity; import android.content.pm.ApplicationInfo; import android.support.v4.app.ActivityCompat; import android.widget.Toast; import and.bruce.com.App; /** * 뒤로가기 버튼을 두 번 눌렀을 때 앱을 종료하게 하는 핸들러 */ public class BackPressCloseHandler { private long backKeyPressedTime = 0; private static final long checkInterval = 2000; private Toast toast;… Read More »