diff --git a/Pi_Bluesky_TFT_Scroller/code.py b/Pi_Bluesky_TFT_Scroller/code.py index de5e37d92..69be8635d 100644 --- a/Pi_Bluesky_TFT_Scroller/code.py +++ b/Pi_Bluesky_TFT_Scroller/code.py @@ -7,6 +7,7 @@ Infinitely scroll Bluesky posts on a 320x240 pixel TFT """ import json import os +import sys import requests import webview @@ -180,10 +181,16 @@ class Api: # pylint: disable=unnecessary-pass pass + def quit(self): + window.destroy() + sys.exit(0) + # create a webview and load the index.html page -webview.create_window( - "bsky posts", "static/index.html", js_api=Api(), width=320, height=240 +window = webview.create_window( + "bsky posts", "static/index.html", js_api=Api(), width=320, height=240, + x=0, y=0, frameless=True, fullscreen=True + ) webview.start() # webview.start(debug=True) # use this one to enable chromium dev tools to see console.log() output from the page. diff --git a/Pi_Bluesky_TFT_Scroller/static/script.js b/Pi_Bluesky_TFT_Scroller/static/script.js index 993ecfdf4..6692428e5 100644 --- a/Pi_Bluesky_TFT_Scroller/static/script.js +++ b/Pi_Bluesky_TFT_Scroller/static/script.js @@ -117,3 +117,10 @@ function autoScroll() { pywebview.api.check_quit(); window.scrollBy(0, 2); } + +document.addEventListener('keydown', function(event){ + /* Quit if the user presses esc key */ + if (event.key === "Escape"){ + pywebview.api.quit(); + } +} ); \ No newline at end of file